From 0ff5c515f7fa483806d75d44b3a1d7de9223a64e Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Fri, 8 Jan 2016 18:01:41 +0000 Subject: [PATCH] Change Log folder search order. So Steam is searched before custom install, to match documentation. --- README.md | 6 +++--- monitor.py | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 6399c10b..0cf835be 100644 --- a/README.md +++ b/README.md @@ -109,9 +109,9 @@ When looking for the log files, this app assumes: In more detail, this app looks for the folder `elite-dangerous-64` in the following places: -1. In the `Products` folder under the launcher (in English versions of Windows usually `C:\Program Files (x86)\Frontier\EDLaunch\Products`). -2. In the `Elite Dangerous Horizons\Products` folder under Steam (in English versions of Windows usually `C:\Program Files (x86)\Steam\steamapps\common\Elite Dangerous Horizons\Products`) and under each Steam library. -3. In the `Elite Dangerous\Products` folder under Steam (in English versions of Windows usually `C:\Program Files (x86)\Steam\steamapps\common\Elite Dangerous\Products`). +1. In the `Elite Dangerous Horizons\Products` folder under Steam (in English versions of Windows usually `C:\Program Files (x86)\Steam\steamapps\common\Elite Dangerous Horizons\Products`) and under each Steam library. +2. In the `Elite Dangerous\Products` folder under Steam (in English versions of Windows usually `C:\Program Files (x86)\Steam\steamapps\common\Elite Dangerous\Products`) and under each Steam library. +3. In the `Products` folder under the launcher (in English versions of Windows usually `C:\Program Files (x86)\Frontier\EDLaunch\Products`). 4. `%PROGRAMFILES(X86)%\Frontier\Products` (in English versions of Windows usually `C:\Program Files (x86)\Frontier\Products`). 5. `%LOCALAPPDATA%\Frontier_Developments\Products` (usually `C:\Users\you\AppData\Local\Frontier_Developments\Products`). diff --git a/monitor.py b/monitor.py index db9ddb66..73e1a5ad 100644 --- a/monitor.py +++ b/monitor.py @@ -256,9 +256,32 @@ class EDLogs(FileSystemEventHandler): def _logdir(self): + # Try locations described in https://support.elitedangerous.com/kb/faq.php?id=108, in reverse order of age candidates = [] - # First try under the Launcher + # Steam and Steam libraries + if not RegOpenKeyEx(HKEY_CURRENT_USER, r'Software\Valve\Steam', 0, KEY_READ, ctypes.byref(key)): + valtype = DWORD() + valsize = DWORD() + if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), None, ctypes.byref(valsize)) and valtype.value == REG_SZ: + buf = ctypes.create_unicode_buffer(size.value / 2) + if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), buf, ctypes.byref(valsize)): + steamlibs = [buf.value] + try: + # Simple-minded Valve VDF parser + with open(join(buf.value, 'config', 'config.vdf'), 'rU') as h: + for line in h: + vals = line.split() + if vals and vals[0].startswith('"BaseInstallFolder_'): + steamlibs.append(vals[1].strip('"')) + except: + pass + for lib in steamlibs: + candidates.append(join(lib, 'steamapps', 'common', 'Elite Dangerous Horizons', 'Products')) + candidates.append(join(lib, 'steamapps', 'common', 'Elite Dangerous', 'Products')) + RegCloseKey(key) + + # Next try custom installation under the Launcher key = HKEY() if not RegOpenKeyEx(HKEY_LOCAL_MACHINE, machine().endswith('64') and @@ -286,29 +309,7 @@ class EDLogs(FileSystemEventHandler): i += 1 RegCloseKey(key) - # Next try locations described in https://support.elitedangerous.com/kb/faq.php?id=108, in reverse order of age - - if not RegOpenKeyEx(HKEY_CURRENT_USER, r'Software\Valve\Steam', 0, KEY_READ, ctypes.byref(key)): - valtype = DWORD() - valsize = DWORD() - if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), None, ctypes.byref(valsize)) and valtype.value == REG_SZ: - buf = ctypes.create_unicode_buffer(size.value / 2) - if not RegQueryValueEx(key, 'SteamPath', 0, ctypes.byref(valtype), buf, ctypes.byref(valsize)): - steamlibs = [buf.value] - try: - # Simple-minded Valve VDF parser - with open(join(buf.value, 'config', 'config.vdf'), 'rU') as h: - for line in h: - vals = line.split() - if vals and vals[0].startswith('"BaseInstallFolder_'): - steamlibs.append(vals[1].strip('"')) - except: - pass - for lib in steamlibs: - candidates.append(join(lib, 'steamapps', 'common', 'Elite Dangerous Horizons', 'Products')) - candidates.append(join(lib, 'steamapps', 'common', 'Elite Dangerous', 'Products')) - RegCloseKey(key) - + # Standard non-Steam locations programs = ctypes.create_unicode_buffer(MAX_PATH) ctypes.windll.shell32.SHGetSpecialFolderPathW(0, programs, CSIDL_PROGRAM_FILESX86, 0) candidates.append(join(programs.value, 'Frontier', 'Products')),