diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/all.dsw | 18 | ||||
-rw-r--r-- | cpp/src/IcePatch/Util.cpp | 76 |
2 files changed, 84 insertions, 10 deletions
diff --git a/cpp/all.dsw b/cpp/all.dsw index 6b4c65f5e08..e775f585443 100644 --- a/cpp/all.dsw +++ b/cpp/all.dsw @@ -138,6 +138,24 @@ Package=<4> ###############################################################################
+Project: "IcePatch"=.\src\IcePatch\IcePatch.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name Ice
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name IceUtil
+ End Project Dependency
+}}}
+
+###############################################################################
+
Project: "IceStorm"=.\src\IceStorm\IceStorm.dsp - Package Owner=<4>
Package=<5>
diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp index 5be60f999e8..f230706c013 100644 --- a/cpp/src/IcePatch/Util.cpp +++ b/cpp/src/IcePatch/Util.cpp @@ -13,11 +13,19 @@ #include <fstream> #include <sys/types.h> #include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> #include <openssl/md5.h> #include <bzlib.h> +#ifndef WIN32 +# include <unistd.h> +# include <dirent.h> +#else +# include <direct.h> +# include <io.h> +# define S_ISDIR(mode) ((mode) & _S_IFDIR) +# define S_ISREG(mode) ((mode) & _S_IFREG) +#endif + using namespace std; using namespace Ice; using namespace IcePatch; @@ -55,19 +63,19 @@ normalizePath(const string& path) } string -IcePatch::identityToPath(const Identity& identity) +IcePatch::identityToPath(const Identity& ident) { - assert(identity.category == "IcePatch"); - return normalizePath(identity.name); + assert(ident.category == "IcePatch"); + return normalizePath(ident.name); } Identity IcePatch::pathToIdentity(const string& path) { - Identity identity; - identity.category = "IcePatch"; - identity.name = normalizePath(path); - return identity; + Identity ident; + ident.category = "IcePatch"; + ident.name = normalizePath(path); + return ident; } string @@ -132,6 +140,48 @@ IcePatch::getFileInfo(const string& path) StringSeq IcePatch::readDirectory(const string& path) { +#ifdef WIN32 + + struct _finddata_t data; + long h = _findfirst(path.c_str(), &data); + if (h == -1) + { + NodeAccessException ex; + ex.reason = "cannot read directory `" + path + "': " + strerror(errno); + throw ex; + } + + StringSeq result; + + while (true) + { + string name = data.name; + + if (name != ".." && name != ".") + { + result.push_back(path + '/' + name); + } + + if (_findnext(h, &data) == -1) + { + if (errno == ENOENT) + { + break; + } + + NodeAccessException ex; + ex.reason = "cannot read directory `" + path + "': " + strerror(errno); + _findclose(h); + throw ex; + } + } + + _findclose(h); + + return result; + +#else + struct dirent **namelist; int n = ::scandir(path.c_str(), &namelist, 0, alphasort); if (n < 0) @@ -149,7 +199,7 @@ IcePatch::readDirectory(const string& path) string name = namelist[i]->d_name; free(namelist[i]); - + if (name != ".." && name != ".") { result.push_back(path + '/' + name); @@ -158,6 +208,8 @@ IcePatch::readDirectory(const string& path) free(namelist); return result; + +#endif } void @@ -184,7 +236,11 @@ IcePatch::removeRecursive(const string& path) void IcePatch::createDirectory(const string& path) { +#ifdef WIN32 + if (::_mkdir(path.c_str()) == -1) +#else if (::mkdir(path.c_str(), 00777) == -1) +#endif { NodeAccessException ex; ex.reason = "cannot create directory `" + path + "': " + strerror(errno); |