diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-01-09T14·52+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-01-09T14·52+0000 |
commit | 5b527901ae625675f525dd65b82f90bcb2001afd (patch) | |
tree | ac6c1aeeb01aa5a3ef2d2a7732f0650b29a45fc9 /src/libutil | |
parent | 04be39734f6a5fe2e724a0c7b813ea1dd6ed3a29 (diff) |
* dirOf: return "/", not "", for paths in the root directory. Fixes NIX-26.
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 188453d16abd..ee34cb18a59e 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -115,7 +115,7 @@ Path dirOf(const Path & path) unsigned int pos = path.rfind('/'); if (pos == string::npos) throw Error(format("invalid file name: %1%") % path); - return Path(path, 0, pos); + return pos == 0 ? "/" : Path(path, 0, pos); } @@ -302,7 +302,7 @@ Path createTempDir() void createDirs(const Path & path) { - if (path == "") return; + if (path == "/") return; createDirs(dirOf(path)); if (!pathExists(path)) if (mkdir(path.c_str(), 0777) == -1) |