16 bool exists(
const std::string& filename )
20 if(stat(filename.c_str(), &info) < 0)
24 return S_ISREG(info.st_mode);
28 if(_stat64(filename.c_str(), &info) < 0)
32 return (info.st_mode & _S_IFREG);
37 size_t timestamp(
const std::string& filename )
41 if(stat(filename.c_str(), &info) < 0)
45 if(S_ISREG(info.st_mode))
46 return size_t(info.st_mtime);
50 if(_stat64(filename.c_str(), &info) < 0)
54 if(info.st_mode & _S_IFREG)
55 return size_t(info.st_mtime);
68 std::string
pathname(
const std::string& filename )
70 std::string path= filename;
72 std::replace(path.begin(), path.end(),
'\\',
'/');
73 size_t slash = path.find_last_of(
'/' );
74 if(slash != std::string::npos)
75 return path.substr(0, slash +1);
79 std::replace(path.begin(), path.end(),
'/',
'\\');
80 size_t slash = path.find_last_of(
'\\' );
81 if(slash != std::string::npos)
82 return path.substr(0, slash +1);
89 std::string normalize_filename(
const std::string& filename )
91 std::string path= filename;
93 std::replace(path.begin(), path.end(),
'\\',
'/');
95 std::replace(path.begin(), path.end(),
'/',
'\\');
108 std::string relative_filename(
const std::string& filename,
const std::string& path )
110 std::string relative=
pathname(path);
113 while(filename[i] && relative[i] && filename[i] == relative[i])
116 return filename.substr(i);
std::string pathname(const std::string &filename)