* dirOf: return "/", not "", for paths in the root directory. Fixes NIX-26.
This commit is contained in:
parent
04be39734f
commit
5b527901ae
|
@ -65,7 +65,7 @@ void setLogType(string lt)
|
|||
void checkStoreNotSymlink(Path path)
|
||||
{
|
||||
struct stat st;
|
||||
while (path.size()) {
|
||||
while (path != "/") {
|
||||
if (lstat(path.c_str(), &st))
|
||||
throw SysError(format("getting status of `%1%'") % path);
|
||||
if (S_ISLNK(st.st_mode))
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue