MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / AppendDirectory

Method AppendDirectory

common/FileSystem.cpp:685–725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

683}
684
685std::string Path::AppendDirectory(const std::string_view path, const std::string_view new_dir)
686{
687 std::string ret;
688 if (!new_dir.empty())
689 {
690 const std::string_view::size_type pos = GetLastSeperatorPosition(path, true);
691
692 ret.reserve(path.length() + new_dir.length() + 1);
693 if (pos != std::string_view::npos)
694 PathAppendString(ret, path.substr(0, pos));
695
696 while (!ret.empty() && ret.back() == FS_OSPATH_SEPARATOR_CHARACTER)
697 ret.pop_back();
698
699 if (!ret.empty())
700 ret += FS_OSPATH_SEPARATOR_CHARACTER;
701
702 PathAppendString(ret, new_dir);
703
704 if (pos != std::string_view::npos)
705 {
706 const std::string_view filepart(path.substr(pos));
707 if (!filepart.empty())
708 {
709 ret += FS_OSPATH_SEPARATOR_CHARACTER;
710 PathAppendString(ret, filepart);
711 }
712 }
713 else if (!path.empty())
714 {
715 ret += FS_OSPATH_SEPARATOR_CHARACTER;
716 PathAppendString(ret, path);
717 }
718 }
719 else
720 {
721 PathAppendString(ret, path);
722 }
723
724 return ret;
725}
726
727void Path::AppendDirectory(std::string* path, const std::string_view new_dir)
728{

Callers

nothing calls this directly

Calls 8

GetLastSeperatorPositionFunction · 0.85
PathAppendStringFunction · 0.85
substrMethod · 0.80
emptyMethod · 0.45
reserveMethod · 0.45
lengthMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected