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

Function FileSystemCharacterIsSane

common/FileSystem.cpp:69–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67#endif
68
69static inline bool FileSystemCharacterIsSane(char32_t c, bool strip_slashes)
70{
71#ifdef _WIN32
72 // https://docs.microsoft.com/en-gb/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#naming-conventions
73 if ((c == U'/' || c == U'\\') && strip_slashes)
74 return false;
75
76 if (c == U'<' || c == U'>' || c == U':' || c == U'"' || c == U'|' || c == U'?' || c == U'*' || c == 0 ||
77 c <= static_cast<char32_t>(31))
78 {
79 return false;
80 }
81#else
82 if (c == '/' && strip_slashes)
83 return false;
84
85 // drop asterisks too, they make globbing annoying
86 if (c == '*')
87 return false;
88
89 // macos doesn't allow colons, apparently
90#ifdef __APPLE__
91 if (c == U':')
92 return false;
93#endif
94#endif
95
96 return true;
97}
98
99template <typename T>
100static inline void PathAppendString(std::string& dst, const T& src)

Callers 2

SanitizeFileNameMethod · 0.85
IsValidFileNameMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected