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
Next Next commit
fix: pass by reference logic
  • Loading branch information
Benjamin Coe committed Jan 31, 2020
commit b5cd988ce7fddd536cea6c3700a1f0d047c9a5f9
12 changes: 6 additions & 6 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -588,12 +588,12 @@ 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);
if (path.compare(0, 4, "\\\\?\\", 4) == 0)
path = path.substr(4);
else if (path.compare(0, 8, "\\\\?\\UNC\\", 8) == 0)
*path = "\\\\" + path.substr(8);
path = "\\\\" + path.substr(8);
#endif
}

Expand All @@ -607,7 +607,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 +1458,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