summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-02-03 21:49:32 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-02-27 20:33:38 +0800
commit77b42e34de519d211f7b68330781af67be76fd35 (patch)
tree06718408b92dc516dbddc7156d977cdf74075bbf /src
parent46164ba2126095d4a788062003e3096699565efe (diff)
downloadandroid-node-v8-77b42e34de519d211f7b68330781af67be76fd35.tar.gz
android-node-v8-77b42e34de519d211f7b68330781af67be76fd35.tar.bz2
android-node-v8-77b42e34de519d211f7b68330781af67be76fd35.zip
fs: throw mkdirSync 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>
Diffstat (limited to 'src')
-rw-r--r--src/node_file.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/node_file.cc b/src/node_file.cc
index 5aa82a6a90..ec2e35c25b 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -1025,20 +1025,24 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
static void MKDir(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
- CHECK_GE(args.Length(), 2);
- CHECK(args[1]->IsInt32());
+ const int argc = args.Length();
+ CHECK_GE(argc, 3);
BufferValue path(env->isolate(), args[0]);
CHECK_NE(*path, nullptr);
- int mode = static_cast<int>(args[1]->Int32Value());
+ CHECK(args[1]->IsInt32());
+ const int mode = args[1].As<Int32>()->Value();
FSReqBase* req_wrap = GetReqWrap(env, args[2]);
- if (req_wrap != nullptr) {
+ if (req_wrap != nullptr) { // mkdir(path, mode, req)
AsyncCall(env, req_wrap, args, "mkdir", UTF8, AfterNoArgs,
uv_fs_mkdir, *path, mode);
- } else {
- SYNC_CALL(mkdir, *path, *path, mode)
+ } else { // mkdir(path, mode, undefined, ctx)
+ CHECK_EQ(argc, 4);
+ fs_req_wrap req_wrap;
+ SyncCall(env, args[3], &req_wrap, "mkdir",
+ uv_fs_mkdir, *path, mode);
}
}