diff options
author | Jose <jose@zeroc.com> | 2009-07-29 21:50:06 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2009-07-29 21:50:06 +0200 |
commit | db9adf0e14f01d0aa8eb288a172995847c006f57 (patch) | |
tree | 9690b02e0f0c85377c0feedb18b3a203d73928fb /cpp/src/IceUtil/FileUtil.cpp | |
parent | bug 4003 - update bindist READMEs for bzip2 (diff) | |
download | ice-db9adf0e14f01d0aa8eb288a172995847c006f57.tar.bz2 ice-db9adf0e14f01d0aa8eb288a172995847c006f57.tar.xz ice-db9adf0e14f01d0aa8eb288a172995847c006f57.zip |
Changes for bug 3962 and 4714
Diffstat (limited to 'cpp/src/IceUtil/FileUtil.cpp')
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index ac830069b52..4486bbd0dd9 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -8,6 +8,7 @@ // ********************************************************************** #include <IceUtil/FileUtil.h> +#include <IceUtil/Unicode.h> using namespace std; @@ -51,3 +52,44 @@ IceUtilInternal::isAbsolutePath(const string& path) return path[i] == '/'; #endif } + +// +// Detemine if a directory exists. +// +bool +IceUtilInternal::directoryExists(const string& path) +{ + IceUtilInternal::structstat st; + if(IceUtilInternal::stat(path, &st) != 0 || !S_ISDIR(st.st_mode)) + { + return false; + } + return true; +} + +// +// Determine if a regular file exists. +// +bool +IceUtilInternal::fileExists(const string& path) +{ + IceUtilInternal::structstat st; + if(IceUtilInternal::stat(path, &st) != 0 || !S_ISREG(st.st_mode)) + { + return false; + } + return true; +} + +// +// Stat +// +int +IceUtilInternal::stat(const string& path, structstat* buffer) +{ +#ifdef _WIN32 + return _wstat(IceUtil::stringToWstring(path).c_str(), buffer); +#else + return stat(path.c_str(), buffer); +#endif +} |