proton: Add gamedrive config setting to create an S: drive for the game's library

This commit is contained in:
Andrew Eikum 2020-12-03 13:36:48 -06:00
parent 25a2a690b0
commit 4c0f01e2dc
2 changed files with 32 additions and 0 deletions

31
proton
View file

@ -114,6 +114,19 @@ def getmtimestr(*path_fragments):
except IOError:
return "0"
def try_get_game_library_dir():
if not "STEAM_COMPAT_INSTALL_PATH" in g_session.env or \
not "STEAM_COMPAT_LIBRARY_PATHS" in g_session.env:
return None
#find library path which is a subset of the game path
library_paths = g_session.env["STEAM_COMPAT_LIBRARY_PATHS"].split(":")
for l in library_paths:
if l in g_session.env["STEAM_COMPAT_INSTALL_PATH"]:
return l
return None
EXT2_IOC_GETFLAGS = 0x80086601
EXT2_IOC_SETFLAGS = 0x40086602
@ -558,6 +571,23 @@ class CompatData:
try_copy(g_proton.lib_dir + "wine/vkd3d-proton/d3d12.dll",
self.prefix_dir + "drive_c/windows/syswow64/d3d12.dll")
gamedrive_path = self.prefix_dir + "dosdevices/s:"
if "gamedrive" in g_session.compat_config:
library_dir = try_get_game_library_dir()
if not library_dir:
if os.path.lexists(gamedrive_path):
os.remove(gamedrive_path)
else:
if os.path.lexists(gamedrive_path):
cur_tgt = os.readlink(gamedrive_path)
if cur_tgt != library_dir:
os.remove(gamedrive_path)
os.symlink(library_dir, gamedrive_path)
else:
os.symlink(library_dir, gamedrive_path)
elif os.path.lexists(gamedrive_path):
os.remove(gamedrive_path)
def comma_escaped(s):
escaped = False
idx = -1
@ -693,6 +723,7 @@ class Session:
self.check_environment("PROTON_OLD_GL_STRING", "oldglstr")
self.check_environment("PROTON_NO_WRITE_WATCH", "nowritewatch")
self.check_environment("PROTON_HIDE_NVIDIA_GPU", "hidenvgpu")
self.check_environment("PROTON_SET_GAME_DRIVE", "gamedrive")
if "noesync" in self.compat_config:
self.env.pop("WINEESYNC", "")