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

Method ChangeFileName

common/FileSystem.cpp:653–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653std::string Path::ChangeFileName(const std::string_view path, const std::string_view new_filename)
654{
655 std::string ret;
656 PathAppendString(ret, path);
657
658 const std::string_view::size_type pos = GetLastSeperatorPosition(ret, true);
659 if (pos == std::string_view::npos)
660 {
661 ret.clear();
662 PathAppendString(ret, new_filename);
663 }
664 else
665 {
666 if (!new_filename.empty())
667 {
668 ret.erase(pos);
669 PathAppendString(ret, new_filename);
670 }
671 else
672 {
673 ret.erase(pos - 1);
674 }
675 }
676
677 return ret;
678}
679
680void Path::ChangeFileName(std::string* path, const std::string_view new_filename)
681{

Callers

nothing calls this directly

Calls 5

PathAppendStringFunction · 0.85
GetLastSeperatorPositionFunction · 0.85
clearMethod · 0.45
emptyMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected