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:
@@ -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)
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user