| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bcb35c3 commit 872d68d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3146,21 +3146,8 @@ static void GetFormatOfExtensionlessFile( | |||
| 3146 | 3146 | } | |
| 3147 | 3147 | ||
| 3148 | 3148 | #ifdef _WIN32 | |
| 3149 | - std::wstring ConvertToWideString(const std::string& str) { | ||
| 3150 | - int size_needed = MultiByteToWideChar( | ||
| 3151 | - CP_UTF8, 0, &str[0], static_cast<int>(str.size()), nullptr, 0); | ||
| 3152 | - std::wstring wstrTo(size_needed, 0); | ||
| 3153 | - MultiByteToWideChar(CP_UTF8, | ||
| 3154 | - 0, | ||
| 3155 | - &str[0], | ||
| 3156 | - static_cast<int>(str.size()), | ||
| 3157 | - &wstrTo[0], | ||
| 3158 | - size_needed); | ||
| 3159 | - return wstrTo; | ||
| 3160 | - } | ||
| 3161 | - | ||
| 3162 | 3149 | #define BufferValueToPath(str) \ | |
| 3163 | - std::filesystem::path(ConvertToWideString(str.ToString())) | ||
| 3150 | + std::filesystem::path(ConvertToWideString(str.ToString(), CP_UTF8)) | ||
| 3164 | 3151 | ||
| 3165 | 3152 | std::string ConvertWideToUTF8(const std::wstring& wstr) { | |
| 3166 | 3153 | if (wstr.empty()) return std::string(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -349,8 +349,16 @@ void BindingData::GetNearestParentPackageJSON( | |||
| 349 | 349 | path_value_str.push_back(kPathSeparator); | |
| 350 | 350 | } | |
| 351 | 351 | ||
| 352 | - auto package_json = | ||
| 353 | - TraverseParent(realm, std::filesystem::path(path_value_str)); | ||
| 352 | + std::filesystem::path path; | ||
| 353 | + | ||
| 354 | + #ifdef _WIN32 | ||
| 355 | + std::wstring wide_path = ConvertToWideString(path_value_str, GetACP()); | ||
| 356 | + path = std::filesystem::path(wide_path); | ||
| 357 | + #else | ||
| 358 | + path = std::filesystem::path(path_value_str); | ||
| 359 | + #endif | ||
| 360 | + | ||
| 361 | + auto package_json = TraverseParent(realm, path); | ||
| 354 | 362 | ||
| 355 | 363 | if (package_json != nullptr) { | |
| 356 | 364 | args.GetReturnValue().Set(package_json->Serialize(realm)); | |
@@ -375,8 +383,16 @@ void BindingData::GetNearestParentPackageJSONType( | |||
| 375 | 383 | path_value_str.push_back(kPathSeparator); | |
| 376 | 384 | } | |
| 377 | 385 | ||
| 378 | - auto package_json = | ||
| 379 | - TraverseParent(realm, std::filesystem::path(path_value_str)); | ||
| 386 | + std::filesystem::path path; | ||
| 387 | + | ||
| 388 | + #ifdef _WIN32 | ||
| 389 | + std::wstring wide_path = ConvertToWideString(path_value_str, GetACP()); | ||
| 390 | + path = std::filesystem::path(wide_path); | ||
| 391 | + #else | ||
| 392 | + path = std::filesystem::path(path_value_str); | ||
| 393 | + #endif | ||
| 394 | + | ||
| 395 | + auto package_json = TraverseParent(realm, path); | ||
| 380 | 396 | ||
| 381 | 397 | if (package_json == nullptr) { | |
| 382 | 398 | 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