--------------------------------- FileUtil::ExtractName Extract the filename from a path
| 171 | // Extract the filename from a path |
| 172 | // |
| 173 | std::string FileUtil::ExtractName(std::string const& fileName) |
| 174 | { |
| 175 | // Get the last path delimiter |
| 176 | size_t closestIdx = 0u; |
| 177 | for (char const token : pathDelimiters) |
| 178 | { |
| 179 | size_t index = fileName.rfind(token); |
| 180 | if (index != std::string::npos && index > closestIdx) |
| 181 | { |
| 182 | closestIdx = index; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // if the closest "delimiter is not an actual delimiter", the file has no path attached |
| 187 | if (std::find(pathDelimiters.cbegin(), pathDelimiters.cend(), fileName[closestIdx]) == pathDelimiters.cend()) |
| 188 | { |
| 189 | return fileName; |
| 190 | } |
| 191 | |
| 192 | return fileName.substr(closestIdx + 1); |
| 193 | } |
| 194 | |
| 195 | //--------------------------------- |
| 196 | // FileUtil::ExtractName |
nothing calls this directly
no outgoing calls
no test coverage detected