Skip to content

Commit

Permalink
filesystem::base_name(): use boost::filesystem::path::stem()
Browse files Browse the repository at this point in the history
No need to reinvent the wheel.
  • Loading branch information
jyrkive authored and GregoryLundberg committed Nov 30, 2017
1 parent b1b790f commit bebbfa9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/filesystem_boost.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit bebbfa9

Please sign in to comment.