mirror of
https://github.com/gurrgur/er-patcher.git
synced 2026-06-13 09:47:54 +00:00
Avoid deleting eldenring.exe while it is locked
This commit is contained in:
parent
ebc316f9e3
commit
e9f39e6ae3
1 changed files with 16 additions and 2 deletions
18
er-patcher
18
er-patcher
|
|
@ -7,7 +7,17 @@ from pathlib import Path
|
||||||
import struct
|
import struct
|
||||||
import re
|
import re
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
import os
|
||||||
|
|
||||||
|
def cleanup(game_dir_patched):
|
||||||
|
if game_dir_patched.exists():
|
||||||
|
eldenring_path = game_dir_patched / "eldenring.exe"
|
||||||
|
try:
|
||||||
|
if eldenring_path.exists():
|
||||||
|
os.remove(eldenring_path)
|
||||||
|
rmtree(game_dir_patched)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"er-patcher: could not delete {game_dir_patched}: {e}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
@ -115,6 +125,10 @@ if __name__ == "__main__":
|
||||||
print("er-patcher: remove_60hz_fullscreen pattern scan failed")
|
print("er-patcher: remove_60hz_fullscreen pattern scan failed")
|
||||||
|
|
||||||
game_dir_patched = Path("er-patcher-tmp")
|
game_dir_patched = Path("er-patcher-tmp")
|
||||||
|
|
||||||
|
# make sure a fresh directory is used
|
||||||
|
cleanup(game_dir_patched)
|
||||||
|
|
||||||
if not game_dir_patched.is_dir():
|
if not game_dir_patched.is_dir():
|
||||||
game_dir_patched.mkdir()
|
game_dir_patched.mkdir()
|
||||||
|
|
||||||
|
|
@ -148,5 +162,5 @@ if __name__ == "__main__":
|
||||||
steam_cmd[-1] = Path(steam_cmd[-1]).parent.absolute() / game_dir_patched / ("start_protected_game.exe" if patch.with_eac else patch.executable)
|
steam_cmd[-1] = Path(steam_cmd[-1]).parent.absolute() / game_dir_patched / ("start_protected_game.exe" if patch.with_eac else patch.executable)
|
||||||
subprocess.run(steam_cmd, cwd=steam_cmd[-1].parent.absolute())
|
subprocess.run(steam_cmd, cwd=steam_cmd[-1].parent.absolute())
|
||||||
|
|
||||||
# cleanup
|
# try to remove game_dir_patched
|
||||||
rmtree(game_dir_patched)
|
cleanup(game_dir_patched)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue