|
53 | 53 |
|
54 | 54 | -- A check for if a path is a dir |
55 | 55 | local function is_dir(path) |
56 | | - -- Used for checking if dir |
57 | | - local golib_os = import("os") |
58 | 56 | -- Returns a FileInfo on the current file/path |
59 | | - local file_info, stat_error = golib_os.Stat(path) |
| 57 | + local file_info, stat_error = os.Stat(path) |
60 | 58 | -- Wrap in nil check for file/dirs without read permissions |
61 | 59 | if file_info ~= nil then |
62 | 60 | -- Returns true/false if it's a dir |
@@ -454,10 +452,8 @@ function prompt_delete_at_cursor() |
454 | 452 |
|
455 | 453 | micro.InfoBar():YNPrompt("Do you want to delete the " .. (scanlist[y].dirmsg ~= "" and "dir" or "file") .. ' "' .. scanlist[y].abspath .. '"? (y/n) ', function(yes, canceled) |
456 | 454 | if yes and not canceled then |
457 | | - -- Use Go's os.Remove to delete the file |
458 | | - local go_os = import("os") |
459 | 455 | -- Delete the target (if its a dir then the children too) |
460 | | - local remove_log = go_os.RemoveAll(scanlist[y].abspath) |
| 456 | + local remove_log = os.RemoveAll(scanlist[y].abspath) |
461 | 457 | if remove_log == nil then |
462 | 458 | micro.InfoBar():Message("Filemanager deleted: ", scanlist[y].abspath) |
463 | 459 | -- Remove the target (and all nested) from scanlist[y + 1] |
@@ -602,14 +598,13 @@ end |
602 | 598 |
|
603 | 599 | -- Stat a path to check if it exists, returning true/false |
604 | 600 | local function path_exists(path) |
605 | | - local go_os = import("os") |
606 | 601 | -- Stat the file/dir path we created |
607 | 602 | -- file_stat should be non-nil, and stat_err should be nil on success |
608 | | - local file_stat, stat_err = go_os.Stat(path) |
| 603 | + local file_stat, stat_err = os.Stat(path) |
609 | 604 | -- Check if what we tried to create exists |
610 | 605 | if stat_err ~= nil then |
611 | 606 | -- true/false if the file/dir exists |
612 | | - return go_os.IsExist(stat_err) |
| 607 | + return os.IsExist(stat_err) |
613 | 608 | elseif file_stat ~= nil then |
614 | 609 | -- Assume it exists if no errors |
615 | 610 | return true |
@@ -654,10 +649,8 @@ function rename_at_cursor(bp, args) |
654 | 649 | return |
655 | 650 | end |
656 | 651 |
|
657 | | - -- Use Go's os package for renaming the file/dir |
658 | | - local golib_os = import("os") |
659 | 652 | -- Actually rename the file |
660 | | - local log_out = golib_os.Rename(old_path, new_path) |
| 653 | + local log_out = os.Rename(old_path, new_path) |
661 | 654 | -- Output the log, if any, of the rename |
662 | 655 | if log_out ~= nil then |
663 | 656 | micro.Log("Rename log: ", log_out) |
@@ -717,16 +710,14 @@ local function create_filedir(filedir_name, make_dir) |
717 | 710 | return |
718 | 711 | end |
719 | 712 |
|
720 | | - -- Use Go's os package for creating the files |
721 | | - local golib_os = import("os") |
722 | 713 | -- Create the dir or file |
723 | 714 | if make_dir then |
724 | 715 | -- Creates the dir |
725 | | - golib_os.Mkdir(filedir_path, golib_os.ModePerm) |
| 716 | + os.Mkdir(filedir_path, os.ModePerm) |
726 | 717 | micro.Log("Filemanager created directory: " .. filedir_path) |
727 | 718 | else |
728 | 719 | -- Creates the file |
729 | | - golib_os.Create(filedir_path) |
| 720 | + os.Create(filedir_path) |
730 | 721 | micro.Log("Filemanager created file: " .. filedir_path) |
731 | 722 | end |
732 | 723 |
|
|
0 commit comments