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

Method SplitFirstDirectory

Engine/source/EtCore/FileSystem/FileUtil.cpp:364–388  ·  view source on GitHub ↗

--------------------------------- FileUtil::SplitFirstDirectory Returns the first directory component, if any. The path variable will be modified to contain what is left

Source from the content-addressed store, hash-verified

362// Returns the first directory component, if any. The path variable will be modified to contain what is left
363//
364std::string FileUtil::SplitFirstDirectory(std::string& path)
365{
366 // get the first delimiter
367 size_t closestIdx = std::numeric_limits<size_t>::max();
368 for (char const token : pathDelimiters)
369 {
370 size_t index = path.find(token);
371 if (index != std::string::npos && index < closestIdx)
372 {
373 closestIdx = index;
374 }
375 }
376
377 // if none is found return an empty path
378 if (closestIdx > path.size())
379 {
380 return "";
381 }
382
383 ++closestIdx;
384
385 std::string ret = path.substr(0, closestIdx);
386 path = path.substr(closestIdx);
387 return ret;
388}
389
390//---------------------------------
391// FileUtil::GetAbsolutePath

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected