Skip to content

Commit

Permalink
fs: move ToNamespacedPath dir calls to c++
Browse files Browse the repository at this point in the history
PR-URL: #53630
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Stephen Belanger <[email protected]>
  • Loading branch information
anonrig authored and aduh95 committed Jul 16, 2024
1 parent 77936c3 commit 076e82c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/internal/fs/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down Expand Up @@ -298,7 +298,7 @@ function opendir(path, options, callback) {
req.oncomplete = opendirCallback;

dirBinding.opendir(
pathModule.toNamespacedPath(path),
path,
options.encoding,
req,
);
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/node_dir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit 076e82c

Please sign in to comment.