Changeset 460


Ignore:
Timestamp:
02/03/16 22:59:30 (6 years ago)
Author:
Maciej Komosinski
Message:

Added a function to strip the path component from filename

Location:
cpp/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/stl-util.cpp

    r382 r460  
    151151}
    152152
     153string stripFileDir(const string& filename)
     154{
     155        size_t sep = filename.rfind(PATH_SEPARATOR_CHAR);
     156        if (sep == string::npos) return filename;
     157        return filename.substr(sep+1);
     158}
     159
    153160string getFileExt(const string& filename)
    154161{
  • cpp/common/stl-util.h

    r286 r460  
    4646string getFileExt(const string& filename); // get extension (starting with ".") from filename
    4747string getFileDir(const string& filename); // get path component excluding filename ("" if no dir in file)
     48string stripFileDir(const string& filename); // strip path component from filename
    4849
    4950
Note: See TracChangeset for help on using the changeset viewer.