Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: fix windows bugs and linting
  • Loading branch information
Benjamin Coe committed Jan 31, 2020
commit cfc6bd506c3cb50045a47169f8a9af52065c0728
16 changes: 9 additions & 7 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,14 @@ void AfterOpenFileHandle(uv_fs_t* req) {

// Reverse the logic applied by path.toNamespacedPath() to create a
// namespace-prefixed path.
void FromNamespacedPath(std::string& path) {
void FromNamespacedPath(std::string* path) {
#ifdef _WIN32
if (path.compare(0, 4, "\\\\?\\", 4) == 0)
path = path.substr(4);
else if (path.compare(0, 8, "\\\\?\\UNC\\", 8) == 0)
path = "\\\\" + path.substr(8);
if (path->compare(0, 8, "\\\\?\\UNC\\", 8) == 0) {
*path = path->substr(8);
path->insert(0, "\\\\");
} else if (path->compare(0, 4, "\\\\?\\", 4) == 0) {
*path = path->substr(4);
}
#endif
}

Expand All @@ -607,7 +609,7 @@ void AfterMkdirp(uv_fs_t* req) {
if (after.Proceed()) {
if (!req_wrap->continuation_data()->first_path().empty()) {
std::string first_path(req_wrap->continuation_data()->first_path());
FromNamespacedPath(first_path);
FromNamespacedPath(&first_path);
path = StringBytes::Encode(req_wrap->env()->isolate(), first_path.c_str(),
req_wrap->encoding(),
&error);
Expand Down Expand Up @@ -1458,7 +1460,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
!req_wrap_sync.continuation_data()->first_path().empty()) {
Local<Value> error;
std::string first_path(req_wrap_sync.continuation_data()->first_path());
FromNamespacedPath(first_path);
FromNamespacedPath(&first_path);
MaybeLocal<Value> path = StringBytes::Encode(env->isolate(),
first_path.c_str(),
UTF8, &error);
Expand Down