diff options
author | Joe George <joe@zeroc.com> | 2016-03-17 11:44:37 -0400 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2016-03-17 11:44:37 -0400 |
commit | db1006f76622d1dd995bc1e2c1fc761c6ac7d7c2 (patch) | |
tree | 3c05d7f841a1585360d0a6450748fd6dc26b050c /cpp/src/IceUtil/FileUtil.cpp | |
parent | fixing .gitignore in checksum test (diff) | |
parent | Update Ice Builder for Gradle version to 1.2.1 (diff) | |
download | ice-db1006f76622d1dd995bc1e2c1fc761c6ac7d7c2.tar.bz2 ice-db1006f76622d1dd995bc1e2c1fc761c6ac7d7c2.tar.xz ice-db1006f76622d1dd995bc1e2c1fc761c6ac7d7c2.zip |
Merge remote-tracking branch 'origin/3.6'
Diffstat (limited to 'cpp/src/IceUtil/FileUtil.cpp')
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index ea7fc606e65..4e3dc407804 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) } // +// Determine 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 |