| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b4db32e commit 67cbe1b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -842,19 +842,6 @@ void AfterOpenFileHandle(uv_fs_t* req) { | |||
| 842 | 842 | } | |
| 843 | 843 | } | |
| 844 | 844 | ||
| 845 | - // Reverse the logic applied by path.toNamespacedPath() to create a | ||
| 846 | - // namespace-prefixed path. | ||
| 847 | - void FromNamespacedPath(std::string* path) { | ||
| 848 | - #ifdef _WIN32 | ||
| 849 | - if (path->compare(0, 8, "\\\\?\\UNC\\", 8) == 0) { | ||
| 850 | - *path = path->substr(8); | ||
| 851 | - path->insert(0, "\\\\"); | ||
| 852 | - } else if (path->compare(0, 4, "\\\\?\\", 4) == 0) { | ||
| 853 | - *path = path->substr(4); | ||
| 854 | - } | ||
| 855 | - #endif | ||
| 856 | - } | ||
| 857 | - | ||
| 858 | 845 | void AfterMkdirp(uv_fs_t* req) { | |
| 859 | 846 | FSReqBase* req_wrap = FSReqBase::from_req(req); | |
| 860 | 847 | FSReqAfterScope after(req_wrap, req); | |
@@ -864,7 +851,7 @@ void AfterMkdirp(uv_fs_t* req) { | |||
| 864 | 851 | std::string first_path(req_wrap->continuation_data()->first_path()); | |
| 865 | 852 | if (first_path.empty()) | |
| 866 | 853 | return req_wrap->Resolve(Undefined(req_wrap->env()->isolate())); | |
| 867 | - FromNamespacedPath(&first_path); | ||
| 854 | + node::url::FromNamespacedPath(&first_path); | ||
| 868 | 855 | Local<Value> path; | |
| 869 | 856 | Local<Value> error; | |
| 870 | 857 | if (!StringBytes::Encode(req_wrap->env()->isolate(), first_path.c_str(), | |
@@ -1790,7 +1777,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) { | |||
| 1790 | 1777 | if (!req_wrap_sync.continuation_data()->first_path().empty()) { | |
| 1791 | 1778 | Local<Value> error; | |
| 1792 | 1779 | std::string first_path(req_wrap_sync.continuation_data()->first_path()); | |
| 1793 | - FromNamespacedPath(&first_path); | ||
| 1780 | + node::url::FromNamespacedPath(&first_path); | ||
| 1794 | 1781 | MaybeLocal<Value> path = StringBytes::Encode(env->isolate(), | |
| 1795 | 1782 | first_path.c_str(), | |
| 1796 | 1783 | UTF8, &error); | |
@@ -2900,7 +2887,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) { | |||
| 2900 | 2887 | return; | |
| 2901 | 2888 | } | |
| 2902 | 2889 | ||
| 2903 | - FromNamespacedPath(&initial_file_path.value()); | ||
| 2890 | + node::url::FromNamespacedPath(&initial_file_path.value()); | ||
| 2904 | 2891 | ||
| 2905 | 2892 | for (int i = 0; i < legacy_main_extensions_with_main_end; i++) { | |
| 2906 | 2893 | file_path = *initial_file_path + std::string(legacy_main_extensions[i]); | |
@@ -2935,7 +2922,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) { | |||
| 2935 | 2922 | return; | |
| 2936 | 2923 | } | |
| 2937 | 2924 | ||
| 2938 | - FromNamespacedPath(&initial_file_path.value()); | ||
| 2925 | + node::url::FromNamespacedPath(&initial_file_path.value()); | ||
| 2939 | 2926 | ||
| 2940 | 2927 | for (int i = legacy_main_extensions_with_main_end; | |
| 2941 | 2928 | i < legacy_main_extensions_package_fallback_end; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -536,6 +536,19 @@ std::optional<std::string> FileURLToPath(Environment* env, | |||
| 536 | 536 | #endif // _WIN32 | |
| 537 | 537 | } | |
| 538 | 538 | ||
| 539 | + // Reverse the logic applied by path.toNamespacedPath() to create a | ||
| 540 | + // namespace-prefixed path. | ||
| 541 | + void FromNamespacedPath(std::string* path) { | ||
| 542 | + #ifdef _WIN32 | ||
| 543 | + if (path->compare(0, 8, "\\\\?\\UNC\\", 8) == 0) { | ||
| 544 | + *path = path->substr(8); | ||
| 545 | + path->insert(0, "\\\\"); | ||
| 546 | + } else if (path->compare(0, 4, "\\\\?\\", 4) == 0) { | ||
| 547 | + *path = path->substr(4); | ||
| 548 | + } | ||
| 549 | + #endif | ||
| 550 | + } | ||
| 551 | + | ||
| 539 | 552 | } // namespace url | |
| 540 | 553 | ||
| 541 | 554 | } // namespace node | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,6 +85,7 @@ class BindingData : public SnapshotableObject { | |||
| 85 | 85 | std::string FromFilePath(std::string_view file_path); | |
| 86 | 86 | std::optional<std::string> FileURLToPath(Environment* env, | |
| 87 | 87 | const ada::url_aggregator& file_url); | |
| 88 | + void FromNamespacedPath(std::string* path); | ||
| 88 | 89 | ||
| 89 | 90 | } // namespace url | |
| 90 | 91 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments