diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-28 11:03:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-28 11:03:00 +0200 |
commit | 039f62b48a14fefabae07d8c008e2e131deadfc6 (patch) | |
tree | 109212c7e0633537ea3701b2f3037f909188c92c /butl | |
parent | 31b316e1da75d4da75ee8def2c64fcf03c0dfe8f (diff) |
Add few filesystem function overloads for C-string paths
Diffstat (limited to 'butl')
-rw-r--r-- | butl/filesystem | 15 | ||||
-rw-r--r-- | butl/filesystem.cxx | 18 |
2 files changed, 21 insertions, 12 deletions
diff --git a/butl/filesystem b/butl/filesystem index 41b9266..4b4af6a 100644 --- a/butl/filesystem +++ b/butl/filesystem @@ -36,13 +36,19 @@ namespace butl // this function resolves symlinks. // LIBBUTL_EXPORT bool - file_exists (const path&); + file_exists (const char*); + + inline bool + file_exists (const path& p) {return file_exists (p.string ().c_str ());} // Return true if the path is to an existing directory. Note that // this function resolves symlinks. // LIBBUTL_EXPORT bool - dir_exists (const path&); + dir_exists (const char*); + + inline bool + dir_exists (const path& p) {return dir_exists (p.string ().c_str ());} // Return true if the directory is empty. Note that the path must exist // and be a directory. @@ -217,7 +223,10 @@ namespace butl // symlinks. // LIBBUTL_EXPORT timestamp - file_mtime (const path&); + file_mtime (const char*); + + inline timestamp + file_mtime (const path& p) {return file_mtime (p.string ().c_str ());} // Path permissions. // diff --git a/butl/filesystem.cxx b/butl/filesystem.cxx index 9db8814..5584e00 100644 --- a/butl/filesystem.cxx +++ b/butl/filesystem.cxx @@ -35,14 +35,14 @@ using namespace std; namespace butl { bool - file_exists (const path& p) + file_exists (const char* p) { #ifndef _WIN32 struct stat s; - if (stat (p.string ().c_str (), &s) != 0) + if (stat (p, &s) != 0) #else struct _stat s; - if (_stat (p.string ().c_str (), &s) != 0) + if (_stat (p, &s) != 0) #endif { if (errno == ENOENT || errno == ENOTDIR) @@ -55,14 +55,14 @@ namespace butl } bool - dir_exists (const path& p) + dir_exists (const char* p) { #ifndef _WIN32 struct stat s; - if (stat (p.string ().c_str (), &s) != 0) + if (stat (p, &s) != 0) #else struct _stat s; - if (_stat (p.string ().c_str (), &s) != 0) + if (_stat (p, &s) != 0) #endif { if (errno == ENOENT || errno == ENOTDIR) @@ -294,14 +294,14 @@ namespace butl nsec (...) {return 0;} timestamp - file_mtime (const path& p) + file_mtime (const char* p) { #ifndef _WIN32 struct stat s; - if (stat (p.string ().c_str (), &s) != 0) + if (stat (p, &s) != 0) #else struct _stat s; - if (_stat (p.string ().c_str (), &s) != 0) + if (_stat (p, &s) != 0) #endif { if (errno == ENOENT || errno == ENOTDIR) |