Skip to content

Commit a5304fe

Browse files
authored
First step to make kml_export.lua windows friendly
Replaced "/" with PS like in other scripts
1 parent aaf564b commit a5304fe

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

contrib/kml_export.lua

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ local df = require "lib/dtutils.file"
4242
require "official/yield"
4343
local gettext = dt.gettext
4444

45+
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
46+
4547
du.check_min_api_version("3.0.0", kml_export)
4648

4749
-- Tell gettext where to find the .mo file translating messages for a particular domain
@@ -260,8 +262,8 @@ local function create_kml_file(storage, image_table, extra_data)
260262
exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string")
261263

262264
-- Creates dir if not exsists
263-
imageFoldername = "files/"
264-
local mkdirCommand = "mkdir -p "..exportDirectory.."/"..imageFoldername
265+
imageFoldername = "files"..PS
266+
local mkdirCommand = "mkdir -p "..exportDirectory..PS..imageFoldername
265267
dt.control.execute(mkdirCommand)
266268
end
267269

@@ -280,7 +282,7 @@ local function create_kml_file(storage, image_table, extra_data)
280282
-- will be scaled so its largest dimension is 120 pixels. The '+profile "*"' removes any ICM, EXIF, IPTC, or other
281283
-- profiles that might be present in the input and aren't needed in the thumbnail.
282284

283-
local convertToThumbCommand = "convert -size 96x96 "..exported_image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory.."/"..imageFoldername.."thumb_"..filename..".jpg"
285+
local convertToThumbCommand = "convert -size 96x96 "..exported_image.." -resize 92x92 -mattecolor \"#FFFFFF\" -frame 2x2 +profile \"*\" "..exportDirectory..PS..imageFoldername.."thumb_"..filename..".jpg"
284286
dt.control.execute(convertToThumbCommand)
285287
else
286288
-- Remove exported image if it has no GPS data
@@ -394,7 +396,7 @@ local function create_kml_file(storage, image_table, extra_data)
394396
kml_file = kml_file.."</Document>\n"
395397
kml_file = kml_file.."</kml>"
396398

397-
local file = io.open(exportDirectory.."/"..exportKMLFilename, "w")
399+
local file = io.open(exportDirectory..PS..exportKMLFilename, "w")
398400
file:write(kml_file)
399401
file:close()
400402

@@ -405,8 +407,8 @@ local function create_kml_file(storage, image_table, extra_data)
405407
exportDirectory = dt.preferences.read("kml_export","ExportDirectory","string")
406408

407409
local createKMZCommand = "zip --test --move --junk-paths "
408-
createKMZCommand = createKMZCommand .."\""..exportDirectory.."/"..exportKMZFilename.."\" " -- KMZ filename
409-
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..exportKMLFilename.."\" " -- KML file
410+
createKMZCommand = createKMZCommand .."\""..exportDirectory..PS..exportKMZFilename.."\" " -- KMZ filename
411+
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir..PS..exportKMLFilename.."\" " -- KML file
410412

411413
for image,exported_image in pairs(image_table) do
412414
if ((image.longitude and image.latitude) and
@@ -416,7 +418,7 @@ local function create_kml_file(storage, image_table, extra_data)
416418
-- Handle duplicates
417419
filename = addDuplicateIndex( image.duplicate_index, filename )
418420

419-
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir.."/"..imageFoldername.."thumb_"..filename..".jpg\" " -- thumbnails
421+
createKMZCommand = createKMZCommand .."\""..dt.configuration.tmp_dir..PS..imageFoldername.."thumb_"..filename..".jpg\" " -- thumbnails
420422
createKMZCommand = createKMZCommand .."\""..exported_image.."\" " -- images
421423
end
422424
end
@@ -429,9 +431,9 @@ local function create_kml_file(storage, image_table, extra_data)
429431
local kmlFileOpenCommand
430432

431433
if ( dt.preferences.read("kml_export","CreateKMZ","bool") == true ) then
432-
kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMZFilename.."\""
434+
kmlFileOpenCommand = "xdg-open "..exportDirectory..PS.."\""..exportKMZFilename.."\""
433435
else
434-
kmlFileOpenCommand = "xdg-open "..exportDirectory.."/\""..exportKMLFilename.."\""
436+
kmlFileOpenCommand = "xdg-open "..exportDirectory..PS.."\""..exportKMLFilename.."\""
435437
end
436438
dt.control.execute(kmlFileOpenCommand)
437439
end

0 commit comments

Comments
 (0)