Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- /** Strips a path from a path+filename string, returning only the filename */
- std::string strip_path(std::string *pth_str, bool lowercase)
- {
- std::size_t found = 0;
- std::size_t found1 = pth_str.find_last_of("/");
- std::size_t found2 = pth_str.find_last_of("\\");
- found = ( found2 > found1 ) ? found2: found1;
- std::string fileonly = pth_str.substr(found+1); //at the slash, plus one
- if(lowercase)
- std::transform(fileonly.begin(), fileonly.end(), fileonly.begin(), ::tolower);
- return fileonly;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement