Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lfs] Check if AppData/ProgramData paths exist #421

Merged
merged 2 commits into from
May 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions legendary/lfs/egl.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,29 @@ def read_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')

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)

def read_manifests(self):
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'))
Expand All @@ -71,6 +81,9 @@ def set_manifest(self, manifest: EGLManifest):
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')
Expand Down