Functions | |
std::string | getFilename (const std::string &path, const char &delimiter= '/') |
Returns the filename of the path. | |
std::string | getExtension (const std::string &path, const char delimiter= '/') |
Returns the extension of the file in the path. |
|
Returns the extension of the file in the path.
Definition at line 37 of file FileUtils.h.
00037 { 00038 // 00039 // variables 00040 // 00041 size_t pos = 0; 00042 size_t len = 0; 00043 00044 00045 pos = path.find_last_of('.'); 00046 if(pos == std::string::npos) { 00047 return "not_found"; 00048 } 00049 len = path.length() - pos; 00050 std::string sub = path.substr(pos + 1, len); 00051 return sub; 00052 } |
|
Returns the filename of the path.
Definition at line 15 of file FileUtils.h.
00015 { 00016 // 00017 // Variables 00018 // 00019 size_t pos = 0; 00020 size_t len = 0; 00021 00022 00023 // Find the last occurence of the delimiter. 00024 // If it is not found, the path contains only a 00025 // filename. 00026 pos = path.find_last_of(delimiter); 00027 if(pos == std::string::npos) { 00028 return path; 00029 } 00030 len = path.size() - pos - 1; 00031 std::string sub = path.substr(pos + 1, len); 00032 return sub; 00033 } |