From bebbfa9a6e53cbb483045c654a93b687274bb8bb Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Tue, 24 Oct 2017 19:22:39 +0300 Subject: [PATCH] filesystem::base_name(): use boost::filesystem::path::stem() No need to reinvent the wheel. --- src/filesystem_boost.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/filesystem_boost.cpp b/src/filesystem_boost.cpp index 7eb30e87ec917..0fea06712617a 100644 --- a/src/filesystem_boost.cpp +++ b/src/filesystem_boost.cpp @@ -948,13 +948,11 @@ int dir_size(const std::string& pname) std::string base_name(const std::string& file, const bool remove_extension) { - std::string res = path(file).filename().string(); - - if(remove_extension) { - return res.substr(0, res.rfind(".")); + if(!remove_extension) { + return path(file).filename().string(); + } else { + return path(file).stem().string(); } - - return res; } std::string directory_name(const std::string& file)