mirror of https://github.com/PrimeDecomp/prime.git
transform-dep: Use $WINEPREFIX/dosdevices
This commit is contained in:
parent
121b5808c0
commit
61bdef3fd2
|
@ -1,6 +1,11 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
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:
|
def import_d_file(in_file) -> str:
|
||||||
out_text = ''
|
out_text = ''
|
||||||
|
@ -19,16 +24,10 @@ def import_d_file(in_file) -> str:
|
||||||
path = line.lstrip()[:-3]
|
path = line.lstrip()[:-3]
|
||||||
else:
|
else:
|
||||||
path = line.strip()
|
path = line.strip()
|
||||||
if path.startswith('Z:'):
|
# lowercase drive letter
|
||||||
# direct mapping to unix path
|
path = path[0].lower() + path[1:]
|
||||||
path = path[2:].replace('\\', '/')
|
# use $WINEPREFIX/dosdevices to resolve path
|
||||||
else:
|
path = os.path.realpath(os.path.join(winedevices, path.replace('\\', '/')))
|
||||||
# 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()
|
|
||||||
out_text += "\t" + path + suffix + "\n"
|
out_text += "\t" + path + suffix + "\n"
|
||||||
|
|
||||||
return out_text
|
return out_text
|
||||||
|
|
Loading…
Reference in New Issue