From c8df40b62cf30029a4acd1a57c8c54add54dda9b Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 20 Jul 2006 17:53:04 +0000 Subject: Utilized the global info object. Utilized the global info object. --- lib/file.cc | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'lib/file.cc') diff --git a/lib/file.cc b/lib/file.cc index 6bd8438..88e8df1 100644 --- a/lib/file.cc +++ b/lib/file.cc @@ -28,6 +28,7 @@ #include "file.h" #include "miav_config.h" +#include "info.h" #include #include @@ -42,12 +43,10 @@ #include -File::File(char *fn, char* ext, Info *i) +File::File(char *fn, char* ext) { char path[256]; - info = i; - savestate = SAVE; filename = new char[strlen(fn) + 1]; @@ -76,9 +75,9 @@ File::~File() { close(fd); - info->info("This session contains the following files..."); + MIaV::info->info("This session contains the following files..."); for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) { - info->info("[%s]", filelist[cnt].c_str()); + MIaV::info->info("[%s]", filelist[cnt].c_str()); } std::string *trash = MIaV::config->readString("server_trash"); @@ -86,20 +85,20 @@ File::~File() switch(savestate) { case NO_CHANGE: - info->warn("File had no savestate!"); + MIaV::info->warn("File had no savestate!"); break; case SAVE: - info->info("Files in this session is to be saved."); + MIaV::info->info("Files in this session is to be saved."); break; case DELETE: - info->info("Files in this session is to be deleted (moved to trash)."); + MIaV::info->info("Files in this session is to be deleted (moved to trash)."); Move((char*)trash->c_str()); break; case LATER: - info->info("Files in this session is stored for later decisson."); + MIaV::info->info("Files in this session is stored for later decisson."); Move((char*)later->c_str()); break; } @@ -122,10 +121,10 @@ int File::Move(char *destination) strcpy(filename, (char*)filelist[cnt].c_str()); sprintf(newfile, "%s%s", destination, strrchr(filename, '/')); if(rename((char*)filelist[cnt].c_str(), newfile) == -1) - info->error("Error moving file %s to %s:", - (char*)filelist[cnt].c_str(), - newfile, - strerror(errno)); + MIaV::info->error("Error moving file %s to %s:", + (char*)filelist[cnt].c_str(), + newfile, + strerror(errno)); } return 0; } @@ -153,7 +152,7 @@ int File::Open() // If more than 100 files are created in one day, something is terribly wrong! if(num > 100) { - info->error("Something is wrong with the path [%s]!", fname); + MIaV::info->error("Something is wrong with the path [%s]!", fname); exit(1); } @@ -164,7 +163,7 @@ int File::Open() seqnum ++; - info->info("Output file: %s", fname); + MIaV::info->info("Output file: %s", fname); return 0; } @@ -176,11 +175,11 @@ int File::Write(void* data, int size) w = write(fd, data, size); if(w != size) { - info->info("Wrapping file."); + MIaV::info->info("Wrapping file."); Open(); w = write(fd, data, size); if(w != size) { - info->error("Out of diskspace!"); + MIaV::info->error("Out of diskspace!"); return -1; } } @@ -201,7 +200,7 @@ int File::createPath(char* path) if(strlen(subpath) > 0) createPath(subpath); - info->info("Checking and/or generating directory: %s", path); + MIaV::info->info("Checking and/or generating directory: %s", path); // stat(path, &stats); //if(!S_ISDIR(stats.st_mode) && S_ISREG(stats.st_mode)) @@ -216,7 +215,7 @@ int File::createPath(char* path) void File::setSaveState(n_savestate s) { savestate = s; - info->info("SETTING SAVESTATE TO: %d", savestate); + MIaV::info->info("SETTING SAVESTATE TO: %d", savestate); } #ifdef __TEST_FILE -- cgit v1.2.3