| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 52ef376 commit 432a4b8
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3047,21 +3047,8 @@ static void GetFormatOfExtensionlessFile( | |||
| 3047 | 3047 | } | |
| 3048 | 3048 | ||
| 3049 | 3049 | #ifdef _WIN32 | |
| 3050 | - std::wstring ConvertToWideString(const std::string& str) { | ||
| 3051 | - int size_needed = MultiByteToWideChar( | ||
| 3052 | - CP_UTF8, 0, &str[0], static_cast<int>(str.size()), nullptr, 0); | ||
| 3053 | - std::wstring wstrTo(size_needed, 0); | ||
| 3054 | - MultiByteToWideChar(CP_UTF8, | ||
| 3055 | - 0, | ||
| 3056 | - &str[0], | ||
| 3057 | - static_cast<int>(str.size()), | ||
| 3058 | - &wstrTo[0], | ||
| 3059 | - size_needed); | ||
| 3060 | - return wstrTo; | ||
| 3061 | - } | ||
| 3062 | - | ||
| 3063 | 3050 | #define BufferValueToPath(str) \ | |
| 3064 | - std::filesystem::path(ConvertToWideString(str.ToString())) | ||
| 3051 | + std::filesystem::path(ConvertToWideString(str.ToString(), CP_UTF8)) | ||
| 3065 | 3052 | ||
| 3066 | 3053 | std::string ConvertWideToUTF8(const std::wstring& wstr) { | |
| 3067 | 3054 | if (wstr.empty()) return std::string(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -344,8 +344,16 @@ void BindingData::GetNearestParentPackageJSON( | |||
| 344 | 344 | path_value_str.push_back(kPathSeparator); | |
| 345 | 345 | } | |
| 346 | 346 | ||
| 347 | - auto package_json = | ||
| 348 | - TraverseParent(realm, std::filesystem::path(path_value_str)); | ||
| 347 | + std::filesystem::path path; | ||
| 348 | + | ||
| 349 | + #ifdef _WIN32 | ||
| 350 | + std::wstring wide_path = ConvertToWideString(path_value_str, GetACP()); | ||
| 351 | + path = std::filesystem::path(wide_path); | ||
| 352 | + #else | ||
| 353 | + path = std::filesystem::path(path_value_str); | ||
| 354 | + #endif | ||
| 355 | + | ||
| 356 | + auto package_json = TraverseParent(realm, path); | ||
| 349 | 357 | ||
| 350 | 358 | if (package_json != nullptr) { | |
| 351 | 359 | args.GetReturnValue().Set(package_json->Serialize(realm)); | |
@@ -370,8 +378,16 @@ void BindingData::GetNearestParentPackageJSONType( | |||
| 370 | 378 | path_value_str.push_back(kPathSeparator); | |
| 371 | 379 | } | |
| 372 | 380 | ||
| 373 | - auto package_json = | ||
| 374 | - TraverseParent(realm, std::filesystem::path(path_value_str)); | ||
| 381 | + std::filesystem::path path; | ||
| 382 | + | ||
| 383 | + #ifdef _WIN32 | ||
| 384 | + std::wstring wide_path = ConvertToWideString(path_value_str, GetACP()); | ||
| 385 | + path = std::filesystem::path(wide_path); | ||
| 386 | + #else | ||
| 387 | + path = std::filesystem::path(path_value_str); | ||
| 388 | + #endif | ||
| 389 | + | ||
| 390 | + auto package_json = TraverseParent(realm, path); | ||
| 375 | 391 | ||
| 376 | 392 | if (package_json == nullptr) { | |
| 377 | 393 | return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -562,6 +562,22 @@ bool IsWindowsBatchFile(const char* filename) { | |||
| 562 | 562 | #endif // _WIN32 | |
| 563 | 563 | } | |
| 564 | 564 | ||
| 565 | + #ifdef _WIN32 | ||
| 566 | + inline std::wstring ConvertToWideString(const std::string& str, | ||
| 567 | + UINT code_page) { | ||
| 568 | + int size_needed = MultiByteToWideChar( | ||
| 569 | + code_page, 0, &str[0], static_cast<int>(str.size()), nullptr, 0); | ||
| 570 | + std::wstring wstrTo(size_needed, 0); | ||
| 571 | + MultiByteToWideChar(code_page, | ||
| 572 | + 0, | ||
| 573 | + &str[0], | ||
| 574 | + static_cast<int>(str.size()), | ||
| 575 | + &wstrTo[0], | ||
| 576 | + size_needed); | ||
| 577 | + return wstrTo; | ||
| 578 | + } | ||
| 579 | + #endif // _WIN32 | ||
| 580 | + | ||
| 565 | 581 | } // namespace node | |
| 566 | 582 | ||
| 567 | 583 | #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS | |
| Back | FazBrowse Home | New Git URL |
0 commit comments