diff options
Diffstat (limited to 'src/file.cc')
-rw-r--r-- | src/file.cc | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/src/file.cc b/src/file.cc index c3fad30..f3c0cbc 100644 --- a/src/file.cc +++ b/src/file.cc @@ -44,6 +44,8 @@ File::File(char *fn, char* ext, Info *i) info = i; + savestate = SAVE; + filename = new char[strlen(fn) + 1]; extension = new char[strlen(ext) + 1]; @@ -70,6 +72,35 @@ File::~File() { close(fd); + info->info("This session contains the following files..."); + for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) { + info->info("[%s]", filelist[cnt].c_str()); + } + + switch(savestate) { + case NO_CHANGE: + info->warn("File had no savestate!"); + break; + + case SAVE: + 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)."); + for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) { + // TODO: Move file filelist[cnt] to trash + } + break; + + case LATER: + info->info("Files in this session is stored for later decisson."); + for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) { + // TODO: Move file filelist[cnt] to the later folder. + } + break; + } + delete filename; delete extension; } @@ -78,8 +109,10 @@ int File::Open() { char fname[256]; - if(fd) close(fd); - fd = -1; + if(fd != -1) { + close(fd); + fd = -1; + } while(fd == -1) { if(seqnum) { @@ -93,14 +126,17 @@ int File::Open() S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if(fd == -1) num ++; - // If more than 1000 files are created in one day, something is terribly wrong! - if(num > 1000) { + // 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); exit(1); } } + std::string filename_string(fname); + filelist.push_back(filename_string); + seqnum ++; info->info("Output file: %s", fname); @@ -245,6 +281,11 @@ int File::createPath(char* path) return 0; } +void File::setSaveState(n_savestate savestate) +{ + this->savestate = savestate; +} + #ifdef __TEST_FILE #include "info_simple.h" |