Update illegal characters in file name for Windows

PiperOrigin-RevId: 767794731
This commit is contained in:
Guogang Li
2025-06-05 15:43:27 -07:00
committed by Copybara-Service
parent 6892dc3495
commit 18bfd5dffa
@@ -57,6 +57,8 @@ constexpr std::wstring_view kForbiddenPathNames[] = {
L"COM5", L"COM6", L"COM7", L"COM8", L"COM9", L"LPT1", L"LPT2", L"LPT3",
L"LPT4", L"LPT5", L"LPT6", L"LPT7", L"LPT8", L"LPT9"};
constexpr char kIllegalFileCharacters[] = {':', '*', '?', '\"', '<', '>', '|'};
std::wstring FilePath::GetCustomSavePath(std::wstring parent_folder,
std::wstring file_name) {
std::wstring path;
@@ -257,8 +259,6 @@ void FilePath::SanitizePath(std::wstring& path) {
ReplaceInvalidCharacters(path);
}
char kIllegalFileCharacters[] = {'?', '*', '\'', '<', '>', '|', ':'};
void FilePath::ReplaceInvalidCharacters(std::wstring& path) {
auto it = path.begin();
it += 2; // Skip the 'C:' or any other drive specifier