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 | |
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')
-rw-r--r-- | cpp/src/IceGrid/IceGridDB.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/Makefile | 2 | ||||
-rw-r--r-- | cpp/src/IceStorm/IceStormDB.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceStorm/Makefile | 2 | ||||
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 39 | ||||
-rw-r--r-- | cpp/src/IceUtil/FileUtil.h | 5 |
6 files changed, 48 insertions, 8 deletions
diff --git a/cpp/src/IceGrid/IceGridDB.cpp b/cpp/src/IceGrid/IceGridDB.cpp index fd4e9ddddc4..04cb5828d6f 100644 --- a/cpp/src/IceGrid/IceGridDB.cpp +++ b/cpp/src/IceGrid/IceGridDB.cpp @@ -14,7 +14,6 @@ #include <Freeze/Freeze.h> #include <Freeze/CatalogIndexList.h> #include <IceGrid/Admin.h> -#include <IcePatch2Lib/Util.h> #include <DBTypes.h> #include <StringApplicationInfoDict.h> #include <StringAdapterInfoDict.h> @@ -144,8 +143,7 @@ Client::run(int argc, char* argv[]) return EXIT_FAILURE; } - StringSeq files = IcePatch2Internal::readDirectory(dbPath); - if(!files.empty()) + if(!IceUtilInternal::isEmptyDirectory(dbPath)) { cerr << argv[0] << ": output directory is not empty: " << dbPath << endl; return EXIT_FAILURE; diff --git a/cpp/src/IceGrid/Makefile b/cpp/src/IceGrid/Makefile index 99d1b1f3d19..afa85e36c75 100644 --- a/cpp/src/IceGrid/Makefile +++ b/cpp/src/IceGrid/Makefile @@ -127,7 +127,7 @@ $(ADMIN): $(ADMIN_OBJS) $(LIBTARGETS) $(DB): $(DB_OBJS) $(LIBTARGETS) rm -f $@ - $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(DB_OBJS) -lIceGrid -lGlacier2 -lIcePatch2 -lFreeze $(LIBS) + $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(DB_OBJS) -lIceGrid -lGlacier2 -lFreeze $(LIBS) $(REGISTRY_SERVER): $(REGISTRY_SVR_OBJS) $(LIBTARGETS) rm -f $@ diff --git a/cpp/src/IceStorm/IceStormDB.cpp b/cpp/src/IceStorm/IceStormDB.cpp index 76b1aa04244..0777c842272 100644 --- a/cpp/src/IceStorm/IceStormDB.cpp +++ b/cpp/src/IceStorm/IceStormDB.cpp @@ -12,7 +12,6 @@ #include <IceUtil/FileUtil.h> #include <Ice/Application.h> #include <Freeze/Freeze.h> -#include <IcePatch2Lib/Util.h> #include <DBTypes.h> #include <LLUMap.h> #include <SubscriberMap.h> @@ -141,8 +140,7 @@ Client::run(int argc, char* argv[]) return EXIT_FAILURE; } - StringSeq files = IcePatch2Internal::readDirectory(dbPath); - if(!files.empty()) + if(!IceUtilInternal::isEmptyDirectory(dbPath)) { cerr << argv[0] << ": output directory is not empty: " << dbPath << endl; return EXIT_FAILURE; diff --git a/cpp/src/IceStorm/Makefile b/cpp/src/IceStorm/Makefile index 203726eda15..83b770860f6 100644 --- a/cpp/src/IceStorm/Makefile +++ b/cpp/src/IceStorm/Makefile @@ -105,7 +105,7 @@ $(ADMIN): $(AOBJS) $(LIBTARGETS) $(DB): $(DOBJS) $(LIBTARGETS) rm -f $@ - $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(DOBJS) -lIceStorm -lIcePatch2 -lFreeze $(LIBS) + $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(DOBJS) -lIceStorm -lFreeze $(LIBS) $(MIGRATE): $(MOBJS) rm -f $@ 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__) |