summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2/Util.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2006-08-09 14:58:01 +0000
committerDwayne Boone <dwayne@zeroc.com>2006-08-09 14:58:01 +0000
commit3f862089b748741b30e343d2051a4747a3bff2f2 (patch)
tree18d1dde1504e2d510a24f4d55aeee21bfea7c04f /cpp/src/IcePatch2/Util.cpp
parentfixing bug 1291 (diff)
downloadice-3f862089b748741b30e343d2051a4747a3bff2f2.tar.bz2
ice-3f862089b748741b30e343d2051a4747a3bff2f2.tar.xz
ice-3f862089b748741b30e343d2051a4747a3bff2f2.zip
Borland C++Builder port mass commit
Diffstat (limited to 'cpp/src/IcePatch2/Util.cpp')
-rw-r--r--cpp/src/IcePatch2/Util.cpp69
1 files changed, 58 insertions, 11 deletions
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index d8522353f21..652e088efd0 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -30,6 +30,10 @@
# include <dirent.h>
#endif
+#ifdef __BCPLUSPLUS__
+# include <iterator>
+#endif
+
const char* IcePatch2::checksumFile = "IcePatch2.sum";
const char* IcePatch2::logFile = "IcePatch2.log";
@@ -426,6 +430,7 @@ IcePatch2::getDirname(const string& pa)
void
IcePatch2::rename(const string& fromPa, const string& toPa)
{
+
const string fromPath = simplify(fromPa);
const string toPath = simplify(toPa);
@@ -452,6 +457,10 @@ IcePatch2::remove(const string& pa)
{
if(OS::rmdir(path) == -1)
{
+ if(errno == EACCES)
+ {
+ assert(false);
+ }
throw "cannot remove directory `" + path + "':\n" + lastError();
}
}
@@ -507,24 +516,25 @@ IcePatch2::readDirectory(const string& pa)
#ifdef _WIN32
- struct _wfinddata_t data;
+ StringSeq result;
const wstring fs = IceUtil::stringToWstring(simplify(path + "/*"));
-#if defined(_MSC_VER) && (_MSC_VER < 1300)
- long h = _wfindfirst(fs.c_str(), &data);
-#else
- intptr_t h = _wfindfirst(fs.c_str(), &data);
-#endif
+# ifdef __BCPLUSPLUS__
+ struct _wffblk data;
+ int h = _wfindfirst(fs.c_str(), &data, FA_DIREC);
if(h == -1)
{
+ if(_doserrno == ENMFILE)
+ {
+ return result;
+ }
throw "cannot read directory `" + path + "':\n" + lastError();
}
- StringSeq result;
while(true)
{
- string name = IceUtil::wstringToString(data.name);
+ string name = IceUtil::wstringToString(data.ff_name);
assert(!name.empty());
if(name != ".." && name != ".")
@@ -532,7 +542,7 @@ IcePatch2::readDirectory(const string& pa)
result.push_back(name);
}
- if(_wfindnext(h, &data) == -1)
+ if(_wfindnext(&data) == -1)
{
if(errno == ENOENT)
{
@@ -540,15 +550,52 @@ IcePatch2::readDirectory(const string& pa)
}
string ex = "cannot read directory `" + path + "':\n" + lastError();
- _findclose(h);
+ _wfindclose(&data);
throw ex;
}
}
+ _wfindclose(&data);
+# else
+ struct _wfinddata_t data;
+
+# if defined(_MSC_VER) && (_MSC_VER < 1300)
+ long h = _wfindfirst(fs.c_str(), &data);
+# else
+ intptr_t h = _wfindfirst(fs.c_str(), &data);
+# endif
+ if(h == -1)
+ {
+ throw "cannot read directory `" + path + "':\n" + lastError();
+ }
+
+ while(true)
+ {
+ string name = IceUtil::wstringToString(data.name);
+ assert(!name.empty());
+
+ if(name != ".." && name != ".")
+ {
+ result.push_back(name);
+ }
+
+ if(_wfindnext(h, &data) == -1)
+ {
+ if(errno == ENOENT)
+ {
+ break;
+ }
+
+ string ex = "cannot read directory `" + path + "':\n" + lastError();
+ _findclose(h);
+ throw ex;
+ }
+ }
+
_findclose(h);
+# endif
sort(result.begin(), result.end());
-
return result;
#else