diff options
author | Jose <jose@zeroc.com> | 2016-03-15 10:14:53 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2016-03-15 10:14:53 +0100 |
commit | a211fe1bbcb8e160136f3dd22b516ba751d4b02e (patch) | |
tree | 3373d05751d651092ee74cb23b7bf4bc17b848b6 /cpp/src/IceUtil | |
parent | .gitignore updates (diff) | |
download | ice-a211fe1bbcb8e160136f3dd22b516ba751d4b02e.tar.bz2 ice-a211fe1bbcb8e160136f3dd22b516ba751d4b02e.tar.xz ice-a211fe1bbcb8e160136f3dd22b516ba751d4b02e.zip |
ICE-7019 - remove db tools dependency on IcePatch2
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 39 | ||||
-rw-r--r-- | cpp/src/IceUtil/FileUtil.h | 5 |
2 files changed, 44 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index ea7fc606e65..dfcbf670b5c 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -17,8 +17,12 @@ #ifdef _WIN32 # include <process.h> # include <io.h> +# ifndef ICE_OS_WINRT +# include <Shlwapi.h> +# endif #else # include <unistd.h> +# include <dirent.h> #endif using namespace std; @@ -90,6 +94,41 @@ IceUtilInternal::directoryExists(const string& path) } // +// Determinte if a directory exists and is empty +// +#ifndef ICE_OS_WINRT +bool +IceUtilInternal::isEmptyDirectory(const string& path) +{ +# ifdef _WIN32 + return PathIsDirectoryEmptyW(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str()); +# else + struct dirent* d; + DIR* dir = opendir(path.c_str()); + if(dir) + { + bool empty = true; + while((d = readdir(dir))) + { + string name(d->d_name); + if(name != "." && name != "..") + { + empty = false; + break; + } + } + closedir(dir); + return empty; + } + else + { + return false; + } +# endif +} +#endif + +// // Determine if a regular file exists. // bool diff --git a/cpp/src/IceUtil/FileUtil.h b/cpp/src/IceUtil/FileUtil.h index 3b148f5dce4..8ff6af42406 100644 --- a/cpp/src/IceUtil/FileUtil.h +++ b/cpp/src/IceUtil/FileUtil.h @@ -40,6 +40,11 @@ ICE_UTIL_API bool fileExists(const std::string&); // ICE_UTIL_API bool directoryExists(const std::string&); +// +// Determinte if a directory exists and is empty +// +ICE_UTIL_API bool isEmptyDirectory(const std::string&); + #ifdef _WIN32 #if defined(__MINGW32__) |