summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/FileUtil.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-03-15 10:14:53 +0100
committerJose <jose@zeroc.com>2016-03-15 10:14:53 +0100
commita211fe1bbcb8e160136f3dd22b516ba751d4b02e (patch)
tree3373d05751d651092ee74cb23b7bf4bc17b848b6 /cpp/src/IceUtil/FileUtil.cpp
parent.gitignore updates (diff)
downloadice-a211fe1bbcb8e160136f3dd22b516ba751d4b02e.tar.bz2
ice-a211fe1bbcb8e160136f3dd22b516ba751d4b02e.tar.xz
ice-a211fe1bbcb8e160136f3dd22b516ba751d4b02e.zip
ICE-7019 - remove db tools dependency on IcePatch2
Diffstat (limited to 'cpp/src/IceUtil/FileUtil.cpp')
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp39
1 files changed, 39 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