aboutsummaryrefslogtreecommitdiff
path: root/libs/basic_games/games/baldursgate3/bg3_utils.py
diff options
context:
space:
mode:
authorSulfurNitride <lukew19@proton.me>2026-05-16 12:56:34 -0500
committerGitHub <noreply@github.com>2026-05-16 12:56:34 -0500
commitfa0579c7f5703aba9669f7f41900c67e9759fca0 (patch)
treef68c7674a3d433d6f9233ad9520a41a634c6bad7 /libs/basic_games/games/baldursgate3/bg3_utils.py
parent95a7f6bc85ec5695388def1ccfd785a631d3958b (diff)
parenta09fb2fbefba58faa0b50eb15dd46945ca288294 (diff)
Merge pull request #78 from saghm/larian-formats
Replace LsLib via proton with native larian-formats Python package
Diffstat (limited to 'libs/basic_games/games/baldursgate3/bg3_utils.py')
-rw-r--r--libs/basic_games/games/baldursgate3/bg3_utils.py38
1 files changed, 26 insertions, 12 deletions
diff --git a/libs/basic_games/games/baldursgate3/bg3_utils.py b/libs/basic_games/games/baldursgate3/bg3_utils.py
index 958d173..23f0a8c 100644
--- a/libs/basic_games/games/baldursgate3/bg3_utils.py
+++ b/libs/basic_games/games/baldursgate3/bg3_utils.py
@@ -1,4 +1,5 @@
import functools
+import os
import shutil
import typing
from pathlib import Path
@@ -73,9 +74,8 @@ class BG3Utils:
def __init__(self, name: str):
self.main_window = None
self._name = name
- from . import lslib_retriever, pak_parser
+ from . import pak_parser
- self.lslib_retriever = lslib_retriever.LSLibRetriever(self)
self._pak_parser = pak_parser.BG3PakParser(self)
def init(self, organizer: mobase.IOrganizer):
@@ -197,10 +197,7 @@ class BG3Utils:
args: str = "",
force_reparse_metadata: bool = False,
) -> bool:
- if (
- "bin/bg3" not in exec_path
- or not self.lslib_retriever.download_lslib_if_missing()
- ):
+ if "bin/bg3" not in exec_path:
return True
active_mods = self.active_mods()
progress = self.create_progress_window(
@@ -262,13 +259,30 @@ class BG3Utils:
return True
def on_mod_installed(self, mod: mobase.IModInterface) -> None:
- if self.lslib_retriever.download_lslib_if_missing():
- self._pak_parser.get_metadata_for_files_in_mod(mod, True)
+ self._pak_parser.get_metadata_for_files_in_mod(mod, True)
def create_dir_if_needed(path: Path) -> Path:
- if "." not in path.name[1:]:
- path.mkdir(parents=True, exist_ok=True)
- else:
- path.parent.mkdir(parents=True, exist_ok=True)
+ target = path if "." not in path.name[1:] else path.parent
+ _mkdir_resolving_symlinks(target)
return path
+
+
+def _mkdir_resolving_symlinks(target: Path) -> None:
+ try:
+ target.mkdir(parents=True, exist_ok=True)
+ return
+ except FileExistsError:
+ pass
+ # A component along the chain exists but is not a directory — typically a
+ # dangling symlink left over from a Wine prefix that points at a Steam
+ # compatdata path that doesn't exist yet. Walk top-down, materialize each
+ # dangling-symlink target as a real directory, then retry.
+ for component in list(reversed(target.parents)) + [target]:
+ if component.is_dir():
+ continue
+ if component.is_symlink():
+ real = Path(os.path.realpath(component))
+ real.mkdir(parents=True, exist_ok=True)
+ continue
+ component.mkdir(exist_ok=True)