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

Method ExtractName

Engine/source/EtCore/FileSystem/FileUtil.cpp:173–193  ·  view source on GitHub ↗

--------------------------------- FileUtil::ExtractName Extract the filename from a path

Source from the content-addressed store, hash-verified

171// Extract the filename from a path
172//
173std::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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected