fs: throw rmdirSync errors in JS
PR-URL: https://github.com/nodejs/node/pull/18871 Refs: https://github.com/nodejs/node/issues/18106 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
29be1e5f84
commit
46164ba212
@ -748,7 +748,9 @@ fs.rmdir = function(path, callback) {
|
||||
fs.rmdirSync = function(path) {
|
||||
path = getPathFromURL(path);
|
||||
validatePath(path);
|
||||
return binding.rmdir(pathModule.toNamespacedPath(path));
|
||||
const ctx = { path };
|
||||
binding.rmdir(pathModule.toNamespacedPath(path), undefined, ctx);
|
||||
handleErrorFromBinding(ctx);
|
||||
};
|
||||
|
||||
fs.fdatasync = function(fd, callback) {
|
||||
|
@ -1004,17 +1004,21 @@ static void Unlink(const FunctionCallbackInfo<Value>& args) {
|
||||
static void RMDir(const FunctionCallbackInfo<Value>& args) {
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
|
||||
CHECK_GE(args.Length(), 1);
|
||||
const int argc = args.Length();
|
||||
CHECK_GE(argc, 2);
|
||||
|
||||
BufferValue path(env->isolate(), args[0]);
|
||||
CHECK_NE(*path, nullptr);
|
||||
|
||||
FSReqBase* req_wrap = GetReqWrap(env, args[1]);
|
||||
FSReqBase* req_wrap = GetReqWrap(env, args[1]); // rmdir(path, req)
|
||||
if (req_wrap != nullptr) {
|
||||
AsyncCall(env, req_wrap, args, "rmdir", UTF8, AfterNoArgs,
|
||||
uv_fs_rmdir, *path);
|
||||
} else {
|
||||
SYNC_CALL(rmdir, *path, *path)
|
||||
} else { // rmdir(path, undefined, ctx)
|
||||
CHECK_EQ(argc, 3);
|
||||
fs_req_wrap req_wrap;
|
||||
SyncCall(env, args[2], &req_wrap, "rmdir",
|
||||
uv_fs_rmdir, *path);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user