@@ -1667,6 +1667,27 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
16671667 }
16681668}
16691669
1670+ static void UnlinkSync (const FunctionCallbackInfo<Value>& args) {
1671+ Environment* env = Environment::GetCurrent (args);
1672+
1673+ const int argc = args.Length ();
1674+ CHECK_GE (argc, 1 );
1675+
1676+ BufferValue path (env->isolate (), args[0 ]);
1677+ CHECK_NOT_NULL (*path);
1678+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1679+ env, permission::PermissionScope::kFileSystemWrite , path.ToStringView ());
1680+
1681+ uv_fs_t req;
1682+ auto make = OnScopeLeave ([&req]() { uv_fs_req_cleanup (&req); });
1683+ FS_SYNC_TRACE_BEGIN (unlink);
1684+ int err = uv_fs_unlink (nullptr , &req, *path, nullptr );
1685+ FS_SYNC_TRACE_END (unlink);
1686+ if (err < 0 ) {
1687+ return env->ThrowUVException (err, " unlink" , nullptr , *path);
1688+ }
1689+ }
1690+
16701691static void RMDir (const FunctionCallbackInfo<Value>& args) {
16711692 Environment* env = Environment::GetCurrent (args);
16721693
@@ -3361,15 +3382,15 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
33613382 Isolate* isolate = isolate_data->isolate ();
33623383
33633384 SetMethod (isolate, target, " access" , Access);
3364- SetMethodNoSideEffect (isolate, target, " accessSync" , AccessSync);
3385+ SetMethod (isolate, target, " accessSync" , AccessSync);
33653386 SetMethod (isolate, target, " close" , Close);
33663387 SetMethod (isolate, target, " closeSync" , CloseSync);
3367- SetMethodNoSideEffect (isolate, target, " existsSync" , ExistsSync);
3388+ SetMethod (isolate, target, " existsSync" , ExistsSync);
33683389 SetMethod (isolate, target, " open" , Open);
33693390 SetMethod (isolate, target, " openSync" , OpenSync);
33703391 SetMethod (isolate, target, " openFileHandle" , OpenFileHandle);
33713392 SetMethod (isolate, target, " read" , Read);
3372- SetMethodNoSideEffect (isolate, target, " readFileUtf8" , ReadFileUtf8);
3393+ SetMethod (isolate, target, " readFileUtf8" , ReadFileUtf8);
33733394 SetMethod (isolate, target, " readBuffers" , ReadBuffers);
33743395 SetMethod (isolate, target, " fdatasync" , Fdatasync);
33753396 SetMethod (isolate, target, " fsync" , Fsync);
@@ -3390,12 +3411,13 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
33903411 SetMethod (isolate, target, " symlink" , Symlink);
33913412 SetMethod (isolate, target, " readlink" , ReadLink);
33923413 SetMethod (isolate, target, " unlink" , Unlink);
3414+ SetMethod (isolate, target, " unlinkSync" , UnlinkSync);
33933415 SetMethod (isolate, target, " writeBuffer" , WriteBuffer);
33943416 SetMethod (isolate, target, " writeBuffers" , WriteBuffers);
33953417 SetMethod (isolate, target, " writeString" , WriteString);
33963418 SetMethod (isolate, target, " realpath" , RealPath);
33973419 SetMethod (isolate, target, " copyFile" , CopyFile);
3398- SetMethodNoSideEffect (isolate, target, " copyFileSync" , CopyFileSync);
3420+ SetMethod (isolate, target, " copyFileSync" , CopyFileSync);
33993421
34003422 SetMethod (isolate, target, " chmod" , Chmod);
34013423 SetMethod (isolate, target, " fchmod" , FChmod);
@@ -3515,6 +3537,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
35153537 registry->Register (Symlink);
35163538 registry->Register (ReadLink);
35173539 registry->Register (Unlink);
3540+ registry->Register (UnlinkSync);
35183541 registry->Register (WriteBuffer);
35193542 registry->Register (WriteBuffers);
35203543 registry->Register (WriteString);
0 commit comments