diff --git a/legendary/lfs/egl.py b/legendary/lfs/egl.py index 88c4cfa..5311e8a 100644 --- a/legendary/lfs/egl.py +++ b/legendary/lfs/egl.py @@ -34,12 +34,18 @@ class EPCLFS: if not self.appdata_path: raise ValueError('EGS AppData path is not set') + if not os.path.isdir(self.appdata_path): + raise ValueError('EGS AppData path does not exist') + self.config.read(os.path.join(self.appdata_path, 'GameUserSettings.ini'), encoding='utf-8') def save_config(self): if not self.appdata_path: raise ValueError('EGS AppData path is not set') + if not os.path.isdir(self.appdata_path): + raise ValueError('EGS AppData path does not exist') + with open(os.path.join(self.appdata_path, 'GameUserSettings.ini'), 'w', encoding='utf-8') as f: self.config.write(f, space_around_delimiters=False) @@ -47,6 +53,10 @@ class EPCLFS: if not self.programdata_path: raise ValueError('EGS ProgramData path is not set') + if not os.path.isdir(self.programdata_path): + # Not sure if we should `raise` here as well + return + for f in os.listdir(self.programdata_path): if f.endswith('.item'): data = json.load(open(os.path.join(self.programdata_path, f), encoding='utf-8')) @@ -71,6 +81,9 @@ class EPCLFS: if not self.programdata_path: raise ValueError('EGS ProgramData path is not set') + if not os.path.isdir(self.programdata_path): + raise ValueError('EGS ProgramData path does not exist') + manifest_data = manifest.to_json() self.manifests[manifest.app_name] = manifest_data _path = os.path.join(self.programdata_path, f'{manifest.installation_guid}.item')