GeezerVison is showing github.com — src: move `FromNamespacedPath` to path.cc · nodejs/node@cc1f497
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_file.cc +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3098,7 +3098,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) { |
3098 | 3098 | return; |
3099 | 3099 | } |
3100 | 3100 |
|
3101 | | - node::url::FromNamespacedPath(&initial_file_path.value()); |
| 3101 | + FromNamespacedPath(&initial_file_path.value()); |
3102 | 3102 |
|
3103 | 3103 | for (int i = 0; i < legacy_main_extensions_with_main_end; i++) { |
3104 | 3104 | file_path = *initial_file_path + std::string(legacy_main_extensions[i]); |
@@ -3133,7 +3133,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) { |
3133 | 3133 | return; |
3134 | 3134 | } |
3135 | 3135 |
|
3136 | | - node::url::FromNamespacedPath(&initial_file_path.value()); |
| 3136 | + FromNamespacedPath(&initial_file_path.value()); |
3137 | 3137 |
|
3138 | 3138 | for (int i = legacy_main_extensions_with_main_end; |
3139 | 3139 | i < legacy_main_extensions_package_fallback_end; |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_url.cc -13Lines changed: 0 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -544,19 +544,6 @@ std::optional<std::string> FileURLToPath(Environment* env, |
544 | 544 | #endif // _WIN32 |
545 | 545 | } |
546 | 546 |
|
547 | | -// Reverse the logic applied by path.toNamespacedPath() to create a |
548 | | -// namespace-prefixed path. |
549 | | -void FromNamespacedPath(std::string* path) { |
550 | | -#ifdef _WIN32 |
551 | | - if (path->compare(0, 8, "\\\\?\\UNC\\", 8) == 0) { |
552 | | - *path = path->substr(8); |
553 | | - path->insert(0, "\\\\"); |
554 | | - } else if (path->compare(0, 4, "\\\\?\\", 4) == 0) { |
555 | | - *path = path->substr(4); |
556 | | - } |
557 | | -#endif |
558 | | -} |
559 | | - |
560 | 547 | } // namespace url |
561 | 548 |
|
562 | 549 | } // namespace node |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_url.h -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -85,7 +85,6 @@ void ThrowInvalidURL(Environment* env, |
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); |
89 | 88 |
|
90 | 89 | } // namespace url |
91 | 90 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: src/path.cc +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -314,4 +314,17 @@ void ToNamespacedPath(Environment* env, BufferValue* path) { |
314 | 314 | #endif |
315 | 315 | } |
316 | 316 |
|
| 317 | +// Reverse the logic applied by path.toNamespacedPath() to create a |
| 318 | +// namespace-prefixed path. |
| 319 | +void FromNamespacedPath(std::string* path) { |
| 320 | +#ifdef _WIN32 |
| 321 | + if (path->starts_with("\\\\?\\UNC\\")) { |
| 322 | + *path = path->substr(8); |
| 323 | + path->insert(0, "\\\\"); |
| 324 | + } else if (path->starts_with("\\\\?\\")) { |
| 325 | + *path = path->substr(4); |
| 326 | + } |
| 327 | +#endif |
| 328 | +} |
| 329 | + |
317 | 330 | } // namespace node |
Collapse file
Copy file name to clipboardExpand all lines: src/path.h +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,6 +24,7 @@ constexpr bool IsWindowsDeviceRoot(const char c) noexcept; |
24 | 24 | #endif // _WIN32 |
25 | 25 |
|
26 | 26 | void ToNamespacedPath(Environment* env, BufferValue* path); |
| 27 | +void FromNamespacedPath(std::string* path); |
27 | 28 |
|
28 | 29 | } // namespace node |
29 | 30 |
|
|