MCPcopy Create free account
hub / github.com/axmolengine/axmol / fullPathForDirectory

Method fullPathForDirectory

core/platform/FileUtils.cpp:708–762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706}
707
708std::string FileUtils::fullPathForDirectory(std::string_view dir) const
709{
710 auto result = std::string();
711
712 if (dir.empty())
713 {
714 // result is ""
715 }
716 else if (isAbsolutePath(dir))
717 {
718 result = dir;
719 }
720 else
721 {
722 // Already Cached ?
723 auto cacheIter = _fullPathCacheDir.find(dir);
724 if (cacheIter != _fullPathCacheDir.end())
725 {
726 result = cacheIter->second;
727 }
728 else
729 {
730 std::string longdir{dir};
731
732 if (longdir[longdir.length() - 1] != '/')
733 {
734 longdir += "/";
735 }
736
737 for (const auto& searchIt : _searchPathArray)
738 {
739 auto fullpath = this->getPathForDirectory(longdir, searchIt);
740 if (!fullpath.empty() && isDirectoryExistInternal(fullpath))
741 {
742 // Using the filename passed in as key.
743 _fullPathCacheDir.emplace(dir, fullpath);
744 result = fullpath;
745 break;
746 }
747 }
748
749 if (result.empty() && isPopupNotify())
750 {
751 AXLOGD("fullPathForDirectory: No directory found at {}. Possible missing directory.", dir);
752 }
753 }
754 }
755
756 if (!result.empty() && result.back() != '/')
757 {
758 result += '/';
759 }
760
761 return result;
762}
763
764std::string FileUtils::fullPathFromRelativeFile(std::string_view filename, std::string_view relativeFile) const
765{

Callers 1

FileUtilsTests.cppFile · 0.80

Calls 7

getPathForDirectoryMethod · 0.95
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
lengthMethod · 0.45
emplaceMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected