diff --git a/src/node_file.cc b/src/node_file.cc index 8717148e6090fa..0ef5fd18b993fd 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1003,24 +1003,7 @@ static void ExistsSync(const FunctionCallbackInfo& args) { THROW_IF_INSUFFICIENT_PERMISSIONS( env, permission::PermissionScope::kFileSystemRead, path.ToStringView()); - uv_fs_t req; - auto make = OnScopeLeave([&req]() { uv_fs_req_cleanup(&req); }); - FS_SYNC_TRACE_BEGIN(access); - int err = uv_fs_access(nullptr, &req, path.out(), 0, nullptr); - FS_SYNC_TRACE_END(access); - -#ifdef _WIN32 - // In case of an invalid symlink, `uv_fs_access` on win32 - // will **not** return an error and is therefore not enough. - // Double check with `uv_fs_stat()`. - if (err == 0) { - FS_SYNC_TRACE_BEGIN(stat); - err = uv_fs_stat(nullptr, &req, path.out(), nullptr); - FS_SYNC_TRACE_END(stat); - } -#endif // _WIN32 - - args.GetReturnValue().Set(err == 0); + args.GetReturnValue().Set(std::filesystem::exists(path.ToStringView())); } // Used to speed up module loading. Returns 0 if the path refers to