| 67 | #endif |
| 68 | |
| 69 | static 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 | |
| 99 | template <typename T> |
| 100 | static inline void PathAppendString(std::string& dst, const T& src) |
no outgoing calls
no test coverage detected