@@ -1025,20 +1025,24 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
10251025static void MKDir (const FunctionCallbackInfo<Value>& args) {
10261026 Environment* env = Environment::GetCurrent (args);
10271027
1028- CHECK_GE ( args.Length (), 2 );
1029- CHECK (args[ 1 ]-> IsInt32 () );
1028+ const int argc = args.Length ();
1029+ CHECK_GE (argc, 3 );
10301030
10311031 BufferValue path (env->isolate (), args[0 ]);
10321032 CHECK_NE (*path, nullptr );
10331033
1034- int mode = static_cast <int >(args[1 ]->Int32Value ());
1034+ CHECK (args[1 ]->IsInt32 ());
1035+ const int mode = args[1 ].As <Int32>()->Value ();
10351036
10361037 FSReqBase* req_wrap = GetReqWrap (env, args[2 ]);
1037- if (req_wrap != nullptr ) {
1038+ if (req_wrap != nullptr ) { // mkdir(path, mode, req)
10381039 AsyncCall (env, req_wrap, args, " mkdir" , UTF8, AfterNoArgs,
10391040 uv_fs_mkdir, *path, mode);
1040- } else {
1041- SYNC_CALL (mkdir, *path, *path, mode)
1041+ } else { // mkdir(path, mode, undefined, ctx)
1042+ CHECK_EQ (argc, 4 );
1043+ fs_req_wrap req_wrap;
1044+ SyncCall (env, args[3 ], &req_wrap, " mkdir" ,
1045+ uv_fs_mkdir, *path, mode);
10421046 }
10431047}
10441048
0 commit comments