removed duplpicate copies of the is_ functions
This commit is contained in:
@@ -773,61 +773,5 @@ function dtutils_file.rmdir(path)
|
||||
return dsys.external_command(rm_cmd.." "..path)
|
||||
end
|
||||
|
||||
function dtutils_file.is_dir(path)
|
||||
local cmd = nil
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
cmd = "if exist " .. ds.sanitize(path .. "\\*")
|
||||
else
|
||||
cmd = "test -d " .. ds.sanitize(path)
|
||||
end
|
||||
|
||||
return os.execute(cmd)
|
||||
end
|
||||
|
||||
function dtutils_file.is_file(path)
|
||||
local cmd = nil
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
if not dtutils_file.is_dir(path) then
|
||||
cmd = "if exist " .. ds.sanitize(path)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else
|
||||
cmd = "test -f " .. ds.sanitize(path)
|
||||
end
|
||||
|
||||
return os.execute(cmd)
|
||||
end
|
||||
|
||||
local function is_windows_executable(path)
|
||||
local result = nil
|
||||
|
||||
if (string.match(path, ".exe$") or string.match(path, ".EXE$")) or
|
||||
(string.match(path, ".com$") or string.match(path, ".COM$")) or
|
||||
(string.match(path, ".bat$") or string.match(path, ".BAT$")) or
|
||||
(string.match(path, ".cmd$") or string.match(path, ".CMD$")) then
|
||||
result = true
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
function dtutils_file.is_executable(path)
|
||||
|
||||
local result = nil
|
||||
|
||||
if dt.configuration.running_os == "windows" then
|
||||
if _is_windows_executable(path) then
|
||||
result = true
|
||||
end
|
||||
else
|
||||
result = os.execute("test -x " .. ds.sanitize(path))
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
return dtutils_file
|
||||
|
||||
|
||||
Reference in New Issue
Block a user