summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2005-03-02 02:06:05 +0000
committerMichi Henning <michi@zeroc.com>2005-03-02 02:06:05 +0000
commitad193ea9e13b334df57472f1b14d7cd4b0545f37 (patch)
tree0f69b35a7b3cc42283d70fc1587408e4616ab94a /cpp/src
parentVC71 release crash work-around (diff)
downloadice-ad193ea9e13b334df57472f1b14d7cd4b0545f37.tar.bz2
ice-ad193ea9e13b334df57472f1b14d7cd4b0545f37.tar.xz
ice-ad193ea9e13b334df57472f1b14d7cd4b0545f37.zip
Fixed bug in IcePatch2: / couldn't be used as the data dir.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IcePatch2/Calc.cpp9
-rwxr-xr-xcpp/src/IcePatch2/ClientUtil.cpp8
-rw-r--r--cpp/src/IcePatch2/Util.cpp37
3 files changed, 42 insertions, 12 deletions
diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp
index 4e4d82d7151..0e4e7e40321 100644
--- a/cpp/src/IcePatch2/Calc.cpp
+++ b/cpp/src/IcePatch2/Calc.cpp
@@ -213,8 +213,13 @@ main(int argc, char* argv[])
}
}
- string absDataDirWithSlash = absDataDir + '/';
-
+ //
+ // We must call simplify() here: under Cygwin, any path starting with
+ // a double slash simply doesn't work. But, if dataDir is "/", we end
+ // up with paths that start with "//" unless we call simplify().
+ //
+ string absDataDirWithSlash = simplify(absDataDir + '/');
+
for(p = fileSeq.begin(); p != fileSeq.end(); ++p)
{
if(p->compare(0, absDataDirWithSlash.size(), absDataDirWithSlash) != 0)
diff --git a/cpp/src/IcePatch2/ClientUtil.cpp b/cpp/src/IcePatch2/ClientUtil.cpp
index fcfb2c0ce94..e5bbed6d9ba 100755
--- a/cpp/src/IcePatch2/ClientUtil.cpp
+++ b/cpp/src/IcePatch2/ClientUtil.cpp
@@ -190,7 +190,7 @@ IcePatch2::Patcher::Patcher(const CommunicatorPtr& communicator, const PatcherFe
}
#endif
- const_cast<string&>(_dataDir) = string(cwd) + '/' + _dataDir;
+ const_cast<string&>(_dataDir) = simplify(string(cwd) + '/' + _dataDir);
}
PropertiesPtr properties = communicator->getProperties();
@@ -475,7 +475,7 @@ IcePatch2::Patcher::patch(const string& d)
}
else
{
- string dirWithSlash = dir + '/';
+ string dirWithSlash = simplify(dir + '/');
FileInfoSeq::const_iterator p;
@@ -706,12 +706,12 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
if(p->size == 0)
{
- string path = _dataDir + '/' + p->path;
+ string path = simplify(_dataDir + '/' + p->path);
ofstream file(path.c_str(), ios::binary);
}
else
{
- string pathBZ2 = _dataDir + '/' + p->path + ".bz2";
+ string pathBZ2 = simplify(_dataDir + '/' + p->path + ".bz2");
string dir = getDirname(pathBZ2);
if(!dir.empty())
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index c8f8ff2b087..7cc6b1442e7 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -247,11 +247,22 @@ IcePatch2::simplify(const string& path)
result.erase(0, 2);
}
+ if(result == "/." ||
+ result.size() == 4 && isalpha(result[0]) && result[1] == ':' && result[2] == '/' && result[3] == '.')
+ {
+ return result.substr(0, result.size() - 1);
+ }
+
if(result.size() >= 2 && result.substr(result.size() - 2, 2) == "/.")
{
result.erase(result.size() - 2, 2);
}
+ if(result == "/" || result.size() == 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/')
+ {
+ return result;
+ }
+
if(result.size() >= 1 && result[result.size() - 1] == '/')
{
result.erase(result.size() - 1);
@@ -275,6 +286,17 @@ IcePatch2::isAbsolute(const string& pa)
#endif
}
+bool
+IcePatch2::isRoot(const string& pa)
+{
+ string path = simplify(pa);
+#ifdef _WIN32
+ return path == "/" || path.size() == 3 && isalpha(path[0]) && path[1] == ':' && path[2] == '/';
+#else
+ return path == "/";
+#endif
+}
+
string
IcePatch2::getSuffix(const string& pa)
{
@@ -417,13 +439,16 @@ IcePatch2::removeRecursive(const string& pa)
removeRecursive(path + '/' + *p);
}
+ if(!isRoot(path))
+ {
#ifdef _WIN32
- if(_rmdir(path.c_str()) == -1)
+ if(_rmdir(path.c_str()) == -1)
#else
- if(rmdir(path.c_str()) == -1)
+ if(rmdir(path.c_str()) == -1)
#endif
- {
- throw "cannot remove directory `" + path + "':\n" + lastError();
+ {
+ throw "cannot remove directory `" + path + "':\n" + lastError();
+ }
}
}
else
@@ -443,7 +468,7 @@ IcePatch2::readDirectory(const string& pa)
#ifdef _WIN32
struct _finddata_t data;
- long h = _findfirst((path + "/*").c_str(), &data);
+ long h = _findfirst(simplify((path + "/*")).c_str(), &data);
if(h == -1)
{
throw "cannot read directory `" + path + "':\n" + lastError();
@@ -698,7 +723,7 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G
return true;
}
- const string path = basePath + '/' + relPath;
+ const string path = simplify(basePath + '/' + relPath);
if(ignoreSuffix(path))
{