summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2/Util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IcePatch2/Util.cpp')
-rw-r--r--cpp/src/IcePatch2/Util.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index 652e088efd0..6959ab8d8d2 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -298,6 +298,11 @@ IcePatch2::simplify(const string& path)
result.erase(pos, 2);
}
+ while(result.substr(0, 4) == "/../")
+ {
+ result.erase(0, 3);
+ }
+
if(result.substr(0, 2) == "./")
{
result.erase(0, 2);
@@ -324,6 +329,11 @@ IcePatch2::simplify(const string& path)
result.erase(result.size() - 1);
}
+ if(result == "/..")
+ {
+ result = "/";
+ }
+
return result;
}
@@ -658,12 +668,15 @@ IcePatch2::createDirectoryRecursive(const string& pa)
createDirectoryRecursive(dir);
}
- if(OS::mkdir(path, 0777) == -1)
+ if(!isRoot(path + "/"))
{
- if(errno != EEXIST)
- {
- throw "cannot create directory `" + path + "':\n" + lastError();
- }
+ if(OS::mkdir(path, 0777) == -1)
+ {
+ if(errno != EEXIST)
+ {
+ throw "cannot create directory `" + path + "':\n" + lastError();
+ }
+ }
}
}