From 692441e1d58d87faa4a1b36007a1c659355ebc91 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 10 Mar 2018 12:52:22 -0500 Subject: [PATCH] Added wine awareness for unix, linux, and macos. Added open -a -W to the macos path so that the path returned by the finder will work correctly. --- lib/dtutils/file.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/dtutils/file.lua b/lib/dtutils/file.lua index 696cdbc..018a74a 100644 --- a/lib/dtutils/file.lua +++ b/lib/dtutils/file.lua @@ -66,7 +66,17 @@ 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 == "linux" or + dt.configuration.running_os == "unix" or + dt.configuration.running_os == "macos") 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 +225,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 @@ -512,6 +523,7 @@ function dtutils_file.executable_path_widget(executables) value = path, is_directory = false, changed_callback = function(self) + dt.print_log("checking that " .. self.value .. " exists") if dtutils_file.check_if_bin_exists(self.value) then dtutils_file.set_executable_path_preference(executable, self.value) end