diff options
-rw-r--r-- | lib/System/Unix/Path.inc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 7ced25ab8d..79786358ac 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -504,19 +504,15 @@ Path::appendSuffix(const std::string& suffix) { bool Path::eraseSuffix() { - std::string save(path); size_t dotpos = path.rfind('.',path.size()); size_t slashpos = path.rfind('/',path.size()); - if (slashpos != std::string::npos && - dotpos != std::string::npos && - dotpos > slashpos) { - path.erase(dotpos, path.size()-dotpos); - } - if (!isValid()) { - path = save; - return false; + if (dotpos != std::string::npos) { + if (slashpos == std::string::npos || dotpos > slashpos) { + path.erase(dotpos, path.size()-dotpos); + return true; + } } - return true; + return false; } bool |