1 #ifndef SCX_FILEHELP_HPP
2 #define SCX_FILEHELP_HPP
13 static inline size_t FileSize(const char* path
)
17 return statbuf
.st_size
;
20 static inline bool CreateFile(const char* path
, uint64_t size
)
22 ofstream
stream(path
, ios::out
);
23 stream
.seekp(size
-1, ios::beg
);
26 return (FileSize(path
) == size
) ? true : false;
29 static inline string
FileSuffix(const string
& name
, char ch
= '.')
31 size_t pos
= name
.find_last_of(ch
);
32 return name
.substr(pos
+1, name
.size());
35 static inline string
FileDir(const string
& path
)
37 size_t pos
= path
.find_last_of('/');
38 if (pos
== string::npos
) {
40 } else if (pos
== path
.size()-1){
41 return path
.substr(0, path
.size());
43 return path
.substr(0, pos
+1);