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

Method IsValidFileName

common/FileSystem.cpp:196–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196bool Path::IsValidFileName(const std::string_view str, bool allow_slashes)
197{
198 const size_t len = str.length();
199 size_t pos = 0;
200 while (pos < len)
201 {
202 char32_t ch;
203 pos += StringUtil::DecodeUTF8(str.data() + pos, pos - len, &ch);
204 if (!FileSystemCharacterIsSane(ch, !allow_slashes))
205 return false;
206 }
207
208#ifdef _WIN32
209 // Windows: Can't end filename with a period.
210 if (len > 0 && str.back() == '.')
211 return false;
212#endif
213
214 return true;
215}
216
217#ifdef _WIN32
218

Callers

nothing calls this directly

Calls 5

DecodeUTF8Function · 0.85
lengthMethod · 0.45
dataMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected