From 61bdef3fd2dd6aaa771cecb80e9e75dcc3ab1b4c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 13 Apr 2022 00:30:20 -0400 Subject: [PATCH] transform-dep: Use $WINEPREFIX/dosdevices --- tools/transform-dep.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tools/transform-dep.py b/tools/transform-dep.py index 18e43071..2698dcd8 100755 --- a/tools/transform-dep.py +++ b/tools/transform-dep.py @@ -1,6 +1,11 @@ #!/usr/bin/env python3 import argparse -import subprocess +import os + +wineprefix = os.path.join(os.environ['HOME'], '.wine') +if 'WINEPREFIX' in os.environ: + wineprefix = os.environ['WINEPREFIX'] +winedevices = os.path.join(wineprefix, 'dosdevices') def import_d_file(in_file) -> str: out_text = '' @@ -19,16 +24,10 @@ def import_d_file(in_file) -> str: path = line.lstrip()[:-3] else: path = line.strip() - if path.startswith('Z:'): - # direct mapping to unix path - path = path[2:].replace('\\', '/') - else: - # use winepath (very slow!) - cmd = subprocess.run(['winepath', '-u', path], capture_output=True, env={'WINEDEBUG': '-all'}) - if cmd.returncode != 0: - print("winepath failed with exit code %d:" % cmd.returncode, cmd.stderr) - exit(1) - path = cmd.stdout.decode('utf-8').rstrip() + # lowercase drive letter + path = path[0].lower() + path[1:] + # use $WINEPREFIX/dosdevices to resolve path + path = os.path.realpath(os.path.join(winedevices, path.replace('\\', '/'))) out_text += "\t" + path + suffix + "\n" return out_text