@@ -349,6 +349,49 @@ int ModApiUtil::l_mkdir(lua_State *L)
349
349
return 1 ;
350
350
}
351
351
352
+ // rmdir(path, recursive)
353
+ int ModApiUtil::l_rmdir (lua_State *L)
354
+ {
355
+ NO_MAP_LOCK_REQUIRED;
356
+ const char *path = luaL_checkstring (L, 1 );
357
+ CHECK_SECURE_PATH (L, path, true );
358
+
359
+ bool recursive = readParam<bool >(L, 2 , false );
360
+
361
+ if (recursive)
362
+ lua_pushboolean (L, fs::RecursiveDelete (path));
363
+ else
364
+ lua_pushboolean (L, fs::DeleteSingleFileOrEmptyDirectory (path));
365
+
366
+ return 1 ;
367
+ }
368
+
369
+ // cpdir(source, destination)
370
+ int ModApiUtil::l_cpdir (lua_State *L)
371
+ {
372
+ NO_MAP_LOCK_REQUIRED;
373
+ const char *source = luaL_checkstring (L, 1 );
374
+ const char *destination = luaL_checkstring (L, 2 );
375
+ CHECK_SECURE_PATH (L, source, false );
376
+ CHECK_SECURE_PATH (L, destination, true );
377
+
378
+ lua_pushboolean (L, fs::CopyDir (source, destination));
379
+ return 1 ;
380
+ }
381
+
382
+ // mpdir(source, destination)
383
+ int ModApiUtil::l_mvdir (lua_State *L)
384
+ {
385
+ NO_MAP_LOCK_REQUIRED;
386
+ const char *source = luaL_checkstring (L, 1 );
387
+ const char *destination = luaL_checkstring (L, 2 );
388
+ CHECK_SECURE_PATH (L, source, true );
389
+ CHECK_SECURE_PATH (L, destination, true );
390
+
391
+ lua_pushboolean (L, fs::MoveDir (source, destination));
392
+ return 1 ;
393
+ }
394
+
352
395
// get_dir_list(path, is_dir)
353
396
int ModApiUtil::l_get_dir_list (lua_State *L)
354
397
{
@@ -588,6 +631,9 @@ void ModApiUtil::Initialize(lua_State *L, int top)
588
631
API_FCT (decompress);
589
632
590
633
API_FCT (mkdir);
634
+ API_FCT (rmdir );
635
+ API_FCT (cpdir);
636
+ API_FCT (mvdir);
591
637
API_FCT (get_dir_list);
592
638
API_FCT (safe_file_write);
593
639
@@ -651,6 +697,9 @@ void ModApiUtil::InitializeAsync(lua_State *L, int top)
651
697
API_FCT (decompress);
652
698
653
699
API_FCT (mkdir);
700
+ API_FCT (rmdir );
701
+ API_FCT (cpdir);
702
+ API_FCT (mvdir);
654
703
API_FCT (get_dir_list);
655
704
656
705
API_FCT (encode_base64);
0 commit comments