aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs
diff options
context:
space:
mode:
authorDenis Krjuchkov <denis@crazydev.net>2013-12-05 04:25:57 +0600
committerDenis Krjuchkov <denis@crazydev.net>2013-12-05 12:27:31 +0600
commit83e6e3e31f2ebf8d7777cdf7e4131996ab94c4a4 (patch)
tree2ae027ed1e44232d0ce847f1d2980d4da9553dcd /src/fs
parentc38703125223b1de11c2cca7b21e5649110a5c51 (diff)
downloadmpd-83e6e3e31f2ebf8d7777cdf7e4131996ab94c4a4.tar.gz
mpd-83e6e3e31f2ebf8d7777cdf7e4131996ab94c4a4.tar.xz
mpd-83e6e3e31f2ebf8d7777cdf7e4131996ab94c4a4.zip
fs/Traits.cxx: don't return empty string if parent dir is root
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/Traits.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/fs/Traits.cxx b/src/fs/Traits.cxx
index 47feda25b..7dd8d20b6 100644
--- a/src/fs/Traits.cxx
+++ b/src/fs/Traits.cxx
@@ -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);
}