Skip to content

Commit 056c380

Browse files
committed
Remove duplicate imports of "os" lib
1 parent 3a116fb commit 056c380

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

filemanager-plugin/filemanager.lua

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ end
5353

5454
-- A check for if a path is a dir
5555
local function is_dir(path)
56-
-- Used for checking if dir
57-
local golib_os = import("os")
5856
-- 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)
6058
-- Wrap in nil check for file/dirs without read permissions
6159
if file_info ~= nil then
6260
-- Returns true/false if it's a dir
@@ -454,10 +452,8 @@ function prompt_delete_at_cursor()
454452

455453
micro.InfoBar():YNPrompt("Do you want to delete the " .. (scanlist[y].dirmsg ~= "" and "dir" or "file") .. ' "' .. scanlist[y].abspath .. '"? (y/n) ', function(yes, canceled)
456454
if yes and not canceled then
457-
-- Use Go's os.Remove to delete the file
458-
local go_os = import("os")
459455
-- 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)
461457
if remove_log == nil then
462458
micro.InfoBar():Message("Filemanager deleted: ", scanlist[y].abspath)
463459
-- Remove the target (and all nested) from scanlist[y + 1]
@@ -602,14 +598,13 @@ end
602598

603599
-- Stat a path to check if it exists, returning true/false
604600
local function path_exists(path)
605-
local go_os = import("os")
606601
-- Stat the file/dir path we created
607602
-- 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)
609604
-- Check if what we tried to create exists
610605
if stat_err ~= nil then
611606
-- true/false if the file/dir exists
612-
return go_os.IsExist(stat_err)
607+
return os.IsExist(stat_err)
613608
elseif file_stat ~= nil then
614609
-- Assume it exists if no errors
615610
return true
@@ -654,10 +649,8 @@ function rename_at_cursor(bp, args)
654649
return
655650
end
656651

657-
-- Use Go's os package for renaming the file/dir
658-
local golib_os = import("os")
659652
-- 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)
661654
-- Output the log, if any, of the rename
662655
if log_out ~= nil then
663656
micro.Log("Rename log: ", log_out)
@@ -717,16 +710,14 @@ local function create_filedir(filedir_name, make_dir)
717710
return
718711
end
719712

720-
-- Use Go's os package for creating the files
721-
local golib_os = import("os")
722713
-- Create the dir or file
723714
if make_dir then
724715
-- Creates the dir
725-
golib_os.Mkdir(filedir_path, golib_os.ModePerm)
716+
os.Mkdir(filedir_path, os.ModePerm)
726717
micro.Log("Filemanager created directory: " .. filedir_path)
727718
else
728719
-- Creates the file
729-
golib_os.Create(filedir_path)
720+
os.Create(filedir_path)
730721
micro.Log("Filemanager created file: " .. filedir_path)
731722
end
732723

0 commit comments

Comments
 (0)