Skip to content

Commit

Permalink
Ported the appimage patch to pathlib. Much nicer code and windows com…
Browse files Browse the repository at this point in the history
…patible.
  • Loading branch information
jnweiger committed Apr 9, 2024
1 parent 5bfbeef commit 4a551e2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/inkscape_extension/visicut_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import random
import string
import socket
from pathlib import Path

try:
from os import fsencode
Expand Down Expand Up @@ -334,13 +335,12 @@ def get_original_filename(filename):
# We detect this by checking for an AppRun file, in one of the parent folders of our INKSCAPEBIN.
# If so, replace INKSCAPEBIN with AppRun, as this is the only safe way to call inkscape.
# (a direct call mixes libraries from the host system with the appimage, may or may not work.)
dir = os.path.dirname(INKSCAPEBIN)
while dir != '/':
apprun_path = os.path.join(dir, "AppRun")
if os.path.exists(apprun_path):
INKSCAPEBIN = apprun_path
for parent in Path(INKSCAPEBIN).parents:
apprun = parent / "AppRun"
if apprun.is_file() and os.access(apprun, os.X_OK):
INKSCAPEBIN = apprun
break
dir = os.path.dirname(dir)

tmpdir = tempfile.mkdtemp(prefix='temp-visicut-')
dest_filename = os.path.join(tmpdir, get_original_filename(filename))

Expand Down

0 comments on commit 4a551e2

Please sign in to comment.