@@ -1694,6 +1694,27 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
1694
1694
}
1695
1695
}
1696
1696
1697
+ static void RMDirSync (const FunctionCallbackInfo<Value>& args) {
1698
+ Environment* env = Environment::GetCurrent (args);
1699
+
1700
+ const int argc = args.Length ();
1701
+ CHECK_GE (argc, 1 );
1702
+
1703
+ BufferValue path (env->isolate (), args[0 ]);
1704
+ CHECK_NOT_NULL (*path);
1705
+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1706
+ env, permission::PermissionScope::kFileSystemWrite , path.ToStringView ());
1707
+
1708
+ uv_fs_t req;
1709
+ auto make = OnScopeLeave ([&req]() { uv_fs_req_cleanup (&req); });
1710
+ FS_SYNC_TRACE_BEGIN (rmdir);
1711
+ int err = uv_fs_rmdir (nullptr , &req, *path, nullptr );
1712
+ FS_SYNC_TRACE_END (rmdir);
1713
+ if (err < 0 ) {
1714
+ return env->ThrowUVException (err, " rmdir" , nullptr , *path);
1715
+ }
1716
+ }
1717
+
1697
1718
int MKDirpSync (uv_loop_t * loop,
1698
1719
uv_fs_t * req,
1699
1720
const std::string& path,
@@ -3365,6 +3386,7 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
3365
3386
SetMethod (isolate, target, " rename" , Rename);
3366
3387
SetMethod (isolate, target, " ftruncate" , FTruncate);
3367
3388
SetMethod (isolate, target, " rmdir" , RMDir);
3389
+ SetMethodNoSideEffect (isolate, target, " rmdirSync" , RMDirSync);
3368
3390
SetMethod (isolate, target, " mkdir" , MKDir);
3369
3391
SetMethod (isolate, target, " readdir" , ReadDir);
3370
3392
SetMethod (isolate, target, " internalModuleReadJSON" , InternalModuleReadJSON);
@@ -3490,6 +3512,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
3490
3512
registry->Register (Rename);
3491
3513
registry->Register (FTruncate);
3492
3514
registry->Register (RMDir);
3515
+ registry->Register (RMDirSync);
3493
3516
registry->Register (MKDir);
3494
3517
registry->Register (ReadDir);
3495
3518
registry->Register (InternalModuleReadJSON);
0 commit comments