MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / GetDirectoryName

Method GetDirectoryName

Sources/Shared/IO/FileSystem.cpp:1033–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031 }
1032
1033 StringView FileSystem::GetDirectoryName(StringView path)
1034 {
1035 if (path.empty()) return {};
1036
1037 std::size_t pathRootLength = GetPathRootLength(path);
1038 std::size_t i = path.size();
1039 // Strip any trailing path separators
1040 while (i > pathRootLength && (path[i - 1] == '/' || path[i - 1] == '\\')) {
1041 i--;
1042 }
1043 if (i <= pathRootLength) return {};
1044 // Try to get the last path separator
1045 while (i > pathRootLength && path[--i] != '/' && path[i] != '\\');
1046
1047 return path.slice(0, i);
1048 }
1049
1050 StringView FileSystem::GetFileName(StringView path)
1051 {

Callers

nothing calls this directly

Calls 4

GetPathRootLengthFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected