Skip to content

Commit 3567562

Browse files
authored
Update gimp.lua
use "lib/dtutils.file"
1 parent 79511d9 commit 3567562

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

contrib/gimp.lua

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
]]
6565

6666
local dt = require "darktable"
67+
local df = require "lib/dtutils.file"
6768
require "official/yield"
68-
6969
local gettext = dt.gettext
7070

7171
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
@@ -104,21 +104,6 @@ local function _(msgid)
104104
return gettext.dgettext("gimp", msgid)
105105
end
106106

107-
local function checkIfBinExists(bin)
108-
local handle = io.popen("which "..bin)
109-
local result = handle:read()
110-
local ret
111-
handle:close()
112-
if (result) then
113-
dt.print_error("true checkIfBinExists: "..bin)
114-
ret = true
115-
else
116-
dt.print_error(bin.." not found")
117-
ret = false
118-
end
119-
return ret
120-
end
121-
122107
-- Thanks Tobias Jakobs for the idea and the correction
123108
function checkIfFileExists(filepath)
124109
local file = io.open(filepath,"r")
@@ -199,7 +184,7 @@ end
199184
local function fileCopy(fromFile, toFile)
200185
local result = nil
201186
-- if cp exists, use it
202-
if checkIfBinExists("cp") then
187+
if df.check_if_bin_exists("cp") then
203188
result = os.execute("cp '" .. fromFile .. "' '" .. toFile .. "'")
204189
end
205190
-- if cp was not present, or if cp failed, then a pure lua solution
@@ -230,7 +215,7 @@ local function fileMove(fromFile, toFile)
230215
local success = os.rename(fromFile, toFile)
231216
if not success then
232217
-- an error occurred, so let's try using the operating system function
233-
if checkIfBinExists("mv") then
218+
if df.check_if_bin_exists("mv") then
234219
success = os.execute("mv '" .. fromFile .. "' '" .. toFile .. "'")
235220
end
236221
-- if the mv didn't exist or succeed, then...
@@ -249,7 +234,7 @@ local function fileMove(fromFile, toFile)
249234
end
250235

251236
local function gimp_edit(storage, image_table, extra_data) --finalize
252-
if not checkIfBinExists("gimp") then
237+
if not df.check_if_bin_exists("gimp") then
253238
dt.print_error(_("GIMP not found"))
254239
return
255240
end

0 commit comments

Comments
 (0)