GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs,url: move `FromNamespacedPath` to `node_url` · nodejs/node@868a464

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_file.cc
    • node_url.cc
    • node_url.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+4-17Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -842,19 +842,6 @@ void AfterOpenFileHandle(uv_fs_t* req) {
842842
}
843843
}
844844

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-
858845
void AfterMkdirp(uv_fs_t* req) {
859846
FSReqBase* req_wrap = FSReqBase::from_req(req);
860847
FSReqAfterScope after(req_wrap, req);
@@ -864,7 +851,7 @@ void AfterMkdirp(uv_fs_t* req) {
864851
std::string first_path(req_wrap->continuation_data()->first_path());
865852
if (first_path.empty())
866853
return req_wrap->Resolve(Undefined(req_wrap->env()->isolate()));
867-
FromNamespacedPath(&first_path);
854+
node::url::FromNamespacedPath(&first_path);
868855
Local<Value> path;
869856
Local<Value> error;
870857
if (!StringBytes::Encode(req_wrap->env()->isolate(), first_path.c_str(),
@@ -1825,7 +1812,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
18251812
if (!req_wrap_sync.continuation_data()->first_path().empty()) {
18261813
Local<Value> error;
18271814
std::string first_path(req_wrap_sync.continuation_data()->first_path());
1828-
FromNamespacedPath(&first_path);
1815+
node::url::FromNamespacedPath(&first_path);
18291816
MaybeLocal<Value> path = StringBytes::Encode(env->isolate(),
18301817
first_path.c_str(),
18311818
UTF8, &error);
@@ -2935,7 +2922,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
29352922
return;
29362923
}
29372924

2938-
FromNamespacedPath(&initial_file_path.value());
2925+
node::url::FromNamespacedPath(&initial_file_path.value());
29392926

29402927
for (int i = 0; i < legacy_main_extensions_with_main_end; i++) {
29412928
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
@@ -2970,7 +2957,7 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
29702957
return;
29712958
}
29722959

2973-
FromNamespacedPath(&initial_file_path.value());
2960+
node::url::FromNamespacedPath(&initial_file_path.value());
29742961

29752962
for (int i = legacy_main_extensions_with_main_end;
29762963
i < legacy_main_extensions_package_fallback_end;
Collapse file

‎src/node_url.cc‎

Copy file name to clipboardExpand all lines: src/node_url.cc
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,19 @@ std::optional<std::string> FileURLToPath(Environment* env,
536536
#endif // _WIN32
537537
}
538538

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+
539552
} // namespace url
540553

541554
} // namespace node
Collapse file

‎src/node_url.h‎

Copy file name to clipboardExpand all lines: src/node_url.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class BindingData : public SnapshotableObject {
8585
std::string FromFilePath(std::string_view file_path);
8686
std::optional<std::string> FileURLToPath(Environment* env,
8787
const ada::url_aggregator& file_url);
88+
void FromNamespacedPath(std::string* path);
8889

8990
} // namespace url
9091

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.