Merge pull request #114 from wpferguson/check_if_bin_exists_fixes

Fix macOS returned path  and add wine awareness to check_if_bin_exists()
This commit is contained in:
supertobi
2018-03-11 16:49:53 +01:00
committed by GitHub

View File

@@ -66,7 +66,14 @@ function dtutils_file.check_if_bin_exists(bin)
if string.len(path) > 0 then
if dtutils_file.check_if_file_exists(path) then
result = "\"" .. path .. "\""
path = "\"" .. path .. "\""
if (string.match(path, ".exe\"$") or string.match(path, ".EXE\"$")) and dt.configuration.running_os ~= "windows" then
result = "wine " .. path
elseif dt.configuration.running_os == "macos" then
result = "open -a -W " .. path
else
result = path
end
end
elseif dt.configuration.running_os == "linux" then
local p = io.popen("which " .. bin)
@@ -215,10 +222,11 @@ dtutils_file.libdoc.functions["check_if_file_exists"] = {
}
function dtutils_file.check_if_file_exists(filepath)
filepath = "\"" .. filepath .. "\""
local result
if (dt.configuration.running_os == 'windows') then
filepath = string.gsub(filepath, '[\\/]+', '\\')
result = os.execute('if exist "'..filepath..'" (cmd /c exit 0) else (cmd /c exit 1)')
result = os.execute('if exist '..filepath..' (cmd /c exit 0) else (cmd /c exit 1)')
if not result then
result = false
end