1
0
mirror of https://github.com/gryf/fs-uae-wrapper.git synced 2025-12-18 20:10:26 +01:00

Prevent from nonexistent paths in config.

In case of defining paths in config, which wrapper is trying to
normalize, sometimes it may happen, that paths can be either local or
remote - depending on the intention, i.e. one can add:

cdrom_drive_0: foo.iso

where foo can be either an unpacked file or just some companion image,
which exists within config file.

In this patch calculated path is checked against file existence, and if
it doesn't exists, original value is preserved.
This commit is contained in:
2021-03-20 13:12:58 +01:00
parent 1559591417
commit 874213aef9
2 changed files with 9 additions and 2 deletions

View File

@@ -219,7 +219,11 @@ class Base(object):
changed_options[key] = abspath
continue
changed_options[key] = os.path.abspath(val)
_val = os.path.abspath(val)
if os.path.exists(_val):
changed_options[key] = _val
else:
changed_options[key] = val
self.fsuae_options.update(changed_options)

View File

@@ -144,6 +144,7 @@ def interpolate_variables(string, config_path, base=None):
- $BASE
"""
_string = string
if '$CONFIG' in string:
conf_path = os.path.dirname(os.path.abspath(config_path))
string = os.path.abspath(string.replace('$CONFIG', conf_path))
@@ -166,7 +167,9 @@ def interpolate_variables(string, config_path, base=None):
if '$BASE' in string:
string = string.replace('$BASE', base)
return string
if os.path.exists(string):
return string
return _string
def get_config(conf_file):