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

Function PathAppendString

common/FileSystem.cpp:100–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99template <typename T>
100static inline void PathAppendString(std::string& dst, const T& src)
101{
102 if (dst.capacity() < (dst.length() + src.length()))
103 dst.reserve(dst.length() + src.length());
104
105 bool last_separator = (!dst.empty() && dst.back() == FS_OSPATH_SEPARATOR_CHARACTER);
106
107 size_t index = 0;
108
109#ifdef _WIN32
110 // special case for UNC paths here
111 if (dst.empty() && src.length() >= 3 && src[0] == '\\' && src[1] == '\\' && src[2] != '\\')
112 {
113 dst.append("\\\\");
114 index = 2;
115 }
116#endif
117
118 for (; index < src.length(); index++)
119 {
120 const char ch = src[index];
121
122#ifdef _WIN32
123 // convert forward slashes to backslashes
124 if (ch == '\\' || ch == '/')
125#else
126 if (ch == '/')
127#endif
128 {
129 if (last_separator)
130 continue;
131 last_separator = true;
132 dst.push_back(FS_OSPATH_SEPARATOR_CHARACTER);
133 }
134 else
135 {
136 last_separator = false;
137 dst.push_back(ch);
138 }
139 }
140}
141
142std::string Path::SanitizeFileName(const std::string_view str, bool strip_slashes /* = true */)
143{

Callers 4

ToNativePathMethod · 0.85
ChangeFileNameMethod · 0.85
AppendDirectoryMethod · 0.85
CombineMethod · 0.85

Calls 7

capacityMethod · 0.45
lengthMethod · 0.45
reserveMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
appendMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected