fs/Traits.cxx: don't return empty string if parent dir is root

This commit is contained in:
Denis Krjuchkov 2013-12-05 04:25:57 +06:00
parent c387031252
commit 83e6e3e31f

View File

@ -64,7 +64,9 @@ PathTraitsUTF8::GetParent(PathTraitsUTF8::const_pointer p)
assert(p != nullptr);
const char *slash = strrchr(p, SEPARATOR);
return slash != nullptr
? std::string(p, slash)
: std::string(".");
if (slash == nullptr)
return std::string(".");
if (slash == p)
return std::string(p, p + 1);
return std::string(p, slash);
}