| 1048 | } |
| 1049 | |
| 1050 | StringView FileSystem::GetFileName(StringView path) |
| 1051 | { |
| 1052 | if (path.empty()) return {}; |
| 1053 | |
| 1054 | std::size_t pathRootLength = GetPathRootLength(path); |
| 1055 | std::size_t pathLength = path.size(); |
| 1056 | // Strip any trailing path separators |
| 1057 | while (pathLength > pathRootLength && (path[pathLength - 1] == '/' || path[pathLength - 1] == '\\')) { |
| 1058 | pathLength--; |
| 1059 | } |
| 1060 | if (pathLength <= pathRootLength) return {}; |
| 1061 | std::size_t i = pathLength; |
| 1062 | // Try to get the last path separator |
| 1063 | while (i > pathRootLength && path[--i] != '/' && path[i] != '\\'); |
| 1064 | |
| 1065 | if (path[i] == '/' || path[i] == '\\') { |
| 1066 | i++; |
| 1067 | } |
| 1068 | return path.slice(i, pathLength); |
| 1069 | } |
| 1070 | |
| 1071 | StringView FileSystem::GetFileNameWithoutExtension(StringView path) |
| 1072 | { |
nothing calls this directly
no test coverage detected