From 18bfd5dffa87d71e45c1ff5838b38da089282509 Mon Sep 17 00:00:00 2001 From: Guogang Li Date: Thu, 5 Jun 2025 15:42:09 -0700 Subject: [PATCH] Update illegal characters in file name for Windows PiperOrigin-RevId: 767794731 --- internal/platform/implementation/windows/file_path.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/platform/implementation/windows/file_path.cc b/internal/platform/implementation/windows/file_path.cc index 3e3c5061..a9b3d1f6 100644 --- a/internal/platform/implementation/windows/file_path.cc +++ b/internal/platform/implementation/windows/file_path.cc @@ -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