fs: move ToNamespacedPath dir calls to c++

PR-URL: https://github.com/nodejs/node/pull/53630
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
Yagiz Nizipli 2024-07-11 14:51:28 -04:00 committed by GitHub
parent 05bb4a716b
commit 3ad2e12073
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -155,7 +155,7 @@ class Dir {
readSyncRecursive(dirent) {
const path = pathModule.join(dirent.parentPath, dirent.name);
const handle = dirBinding.opendir(
pathModule.toNamespacedPath(path),
path,
this.#options.encoding,
);
@ -298,7 +298,7 @@ function opendir(path, options, callback) {
req.oncomplete = opendirCallback;
dirBinding.opendir(
pathModule.toNamespacedPath(path),
path,
options.encoding,
req,
);
@ -308,9 +308,7 @@ function opendirSync(path, options) {
path = getValidatedPath(path);
options = getOptions(options, { encoding: 'utf8' });
const handle = dirBinding.opendirSync(
pathModule.toNamespacedPath(path),
);
const handle = dirBinding.opendirSync(path);
return new Dir(handle, path, options);
}

View File

@ -363,6 +363,7 @@ static void OpenDir(const FunctionCallbackInfo<Value>& args) {
BufferValue path(isolate, args[0]);
CHECK_NOT_NULL(*path);
ToNamespacedPath(env, &path);
const enum encoding encoding = ParseEncoding(isolate, args[1], UTF8);
@ -406,6 +407,7 @@ static void OpenDirSync(const FunctionCallbackInfo<Value>& args) {
BufferValue path(isolate, args[0]);
CHECK_NOT_NULL(*path);
ToNamespacedPath(env, &path);
THROW_IF_INSUFFICIENT_PERMISSIONS(
env, permission::PermissionScope::kFileSystemRead, path.ToStringView());