-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
src: use CP_UTF8 for wide file names on win32 #60575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,22 +296,35 @@ const BindingData::PackageConfig* BindingData::TraverseParent( | |
|
|
||
| // Stop the search when the process doesn't have permissions | ||
| // to walk upwards | ||
| if (is_permissions_enabled && | ||
| !env->permission()->is_granted( | ||
| env, | ||
| permission::PermissionScope::kFileSystemRead, | ||
| current_path.generic_string())) [[unlikely]] { | ||
| return nullptr; | ||
| if (is_permissions_enabled) { | ||
| std::string generic_path; | ||
| #ifdef _WIN32 | ||
| generic_path = ConvertWideToUTF8(current_path.generic_wstring()); | ||
| #else // _WIN32 | ||
| generic_path = current_path.generic_string(); | ||
| #endif // _WIN32 | ||
| // | ||
| if (!env->permission()->is_granted( | ||
| env, permission::PermissionScope::kFileSystemRead, generic_path)) | ||
| [[unlikely]] { | ||
| return nullptr; | ||
| } | ||
| } | ||
|
|
||
| // Check if the path ends with `/node_modules` | ||
| if (current_path.generic_string().ends_with("/node_modules")) { | ||
| if (current_path.filename() == "node_modules") { | ||
| return nullptr; | ||
| } | ||
|
|
||
| auto package_json_path = current_path / "package.json"; | ||
| auto package_json = | ||
| GetPackageJSON(realm, package_json_path.string(), nullptr); | ||
|
|
||
| std::string package_json_path_str; | ||
| #ifdef _WIN32 | ||
| package_json_path_str = ConvertWideToUTF8(package_json_path.wstring()); | ||
| #else // _WIN32 | ||
| package_json_path_str = package_json_path.string(); | ||
| #endif // _WIN32 | ||
| auto package_json = GetPackageJSON(realm, package_json_path_str, nullptr); | ||
| if (package_json != nullptr) { | ||
| return package_json; | ||
| } | ||
|
|
@@ -341,7 +354,7 @@ void BindingData::GetNearestParentPackageJSONType( | |
| std::filesystem::path path; | ||
|
|
||
| #ifdef _WIN32 | ||
| std::wstring wide_path = ConvertToWideString(path_value_str, GetACP()); | ||
| std::wstring wide_path = ConvertToWideString(path_value_str, CP_UTF8); | ||
|
||
| path = std::filesystem::path(wide_path); | ||
| #else | ||
| path = std::filesystem::path(path_value_str); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that the amount of ifdefs sprinkled everywhere is a bit cluttering; it looks like all new usages of these are on a std::filesystem::path, so technically they are just repeating what
PathToString()does, I think we can just putPathToStringtoutil.hand use that instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I think usage of
generic_stringvsstringcomplicates it a bit, but let me see what I can do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about db29a1d? I tried to unify things as much as I could.