MCPcopy Create free account
hub / github.com/Illation/ETEngine / ExtractPath

Method ExtractPath

Engine/source/EtCore/FileSystem/FileUtil.cpp:146–166  ·  view source on GitHub ↗

--------------------------------- FileUtil::ExtractPath Extract the path from a path with file name

Source from the content-addressed store, hash-verified

144// Extract the path from a path with file name
145//
146std::string FileUtil::ExtractPath(std::string const& fileName)
147{
148 // Get the last path delimiter
149 size_t closestIdx = 0u;
150 for (char const token : pathDelimiters)
151 {
152 size_t index = fileName.rfind(token);
153 if (index != std::string::npos && index > closestIdx)
154 {
155 closestIdx = index;
156 }
157 }
158
159 // if the closest "delimiter is not an actual delimiter", the file has no path attached
160 if (std::find(pathDelimiters.cbegin(), pathDelimiters.cend(), fileName[closestIdx]) == pathDelimiters.cend())
161 {
162 return "";
163 }
164
165 return fileName.substr(0, closestIdx + 1);
166}
167
168//---------------------------------
169// FileUtil::ExtractName

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected