Changeset 121 for trunk/IPs/systemC/processor/Morpheo/Common
- Timestamp:
- May 27, 2009, 12:13:56 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Common/include/Filename.h
r100 r121 10 10 11 11 #include "Common/include/ToString.h" 12 #include <fstream> 13 #include <sstream> 14 #include <sys/time.h> 15 #include <unistd.h> 12 #include <string> 16 13 17 14 namespace morpheo { … … 24 21 bool with_pid, 25 22 bool overwrite 26 ) 27 { 28 std::string str = directory+"/"+filename_prefix; 29 30 if (with_date) 31 { 32 time_t current_time; 33 time (¤t_time); 34 35 struct tm * _localtime = localtime (¤t_time); 36 37 int year = 1900+_localtime->tm_year; 38 int mon = 1+_localtime->tm_mon ; 39 int mday = _localtime->tm_mday; 40 int hour = _localtime->tm_hour; 41 int min = _localtime->tm_min ; 42 int sec = _localtime->tm_sec ; 43 44 str+= "_"+ toString<int>(year) 45 +((mon <10)?"0":"") + toString<int>(mon ) 46 +((mday<10)?"0":"") + toString<int>(mday) 47 +"_"+((hour<10)?"0":"") + toString<int>(hour) 48 +((min <10)?"0":"") + toString<int>(min ) 49 +((sec <10)?"0":"") + toString<int>(sec ); 50 } 51 52 if (with_pid) 53 { 54 str+="_"+toString<pid_t>(getpid()); 55 } 56 57 str+=filename_suffix; 58 59 if (not overwrite) 60 { 61 int it = 0; 62 bool find; 63 do 64 { 65 find = false; 66 67 std::ifstream inputStream; 68 std::string name = str+((it!=0)?("_"+toString<int>(it)):""); 69 70 inputStream.open(name.c_str(),std::ios_base::in); 71 72 if (inputStream) 73 { 74 find = true; 75 it ++; 76 } 77 inputStream.close(); 78 } 79 while (find); 80 81 str+= str+((it!=0)?("_"+toString<int>(it)):""); 82 } 83 84 str+="."+extension; 85 86 return str; 87 } 23 ); 88 24 89 25 }; // end namespace morpheo
Note: See TracChangeset
for help on using the changeset viewer.