Skip to content

Commit

Permalink
try with .native()
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Oct 4, 2024
1 parent a706361 commit 6c5b1c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
}

// On Windows path::c_str() returns wide char, convert to std::string first.
std::string file_path_str = file_path.string();
std::string file_path_str = file_path.native();
const char* path_c_str = file_path_str.c_str();
#ifdef _WIN32
int permission_denied_error = EPERM;
Expand Down Expand Up @@ -3180,7 +3180,7 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
// Check if src and dest are identical.
if (std::filesystem::equivalent(src_path, dest_path)) {
std::string message = "src and dest cannot be the same %s";
return THROW_ERR_FS_CP_EINVAL(env, message.c_str(), dest_path.string());
return THROW_ERR_FS_CP_EINVAL(env, message.c_str(), dest_path.native());
}

const bool dest_is_dir =
Expand All @@ -3190,19 +3190,19 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
std::string message =
"Cannot overwrite non-directory %s with directory %s";
return THROW_ERR_FS_CP_DIR_TO_NON_DIR(
env, message.c_str(), src_path.string(), dest_path.string());
env, message.c_str(), src_path.native(), dest_path.native());
}

if (!src_is_dir && dest_is_dir) {
std::string message =
"Cannot overwrite directory %s with non-directory %s";
return THROW_ERR_FS_CP_NON_DIR_TO_DIR(
env, message.c_str(), dest_path.string(), src_path.string());
env, message.c_str(), dest_path.native(), src_path.native());
}
}

std::string dest_path_str = dest_path.string();
std::string src_path_str = src_path.string();
std::string dest_path_str = dest_path.native();
std::string src_path_str = src_path.native();
if (!src_path_str.ends_with(std::filesystem::path::preferred_separator)) {
src_path_str += std::filesystem::path::preferred_separator;
}
Expand Down

0 comments on commit 6c5b1c2

Please sign in to comment.