projects
/
vrfileman
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
removed debug print
[vrfileman]
/
src
/
fspath.cc
diff --git
a/src/fspath.cc
b/src/fspath.cc
index
e6677bd
..
ea8ce6e
100644
(file)
--- a/
src/fspath.cc
+++ b/
src/fspath.cc
@@
-163,8
+163,8
@@
void FSPath::sanitize()
}
assert(len == (int)strlen(abs_path));
}
assert(len == (int)strlen(abs_path));
- // remove trailing slash
- if(abs_path[len - 1] == '/') {
+ // remove trailing slash if abs_path is not just a slash (root)
+ if(len > 1 && abs_path[len - 1] == '/') {
abs_path[--len] = 0;
}
assert(len == (int)strlen(abs_path));
abs_path[--len] = 0;
}
assert(len == (int)strlen(abs_path));
@@
-192,7
+192,11
@@
void FSPath::sanitize()
parent = 0; // root dir has no parent
} else {
int plen = name - 1 - abs_path;
parent = 0; // root dir has no parent
} else {
int plen = name - 1 - abs_path;
- assert(plen > 0);
+ assert(plen >= 0);
+
+ if(plen == 0) {
+ plen = 1; // our parent is root, so we need the slash
+ }
parent = new char[plen + 1];
memcpy(parent, abs_path, plen);
parent = new char[plen + 1];
memcpy(parent, abs_path, plen);