Skip to content
Open
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
21 changes: 17 additions & 4 deletions UnityPy/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,24 @@ def load(self, files: List[str]):
{ntpath.basename(f): self.load_file(self.fs.open(f, "rb"), self, f) for f in files if self.fs.exists(f)}
)

def _load_split_file(self, basename: str) -> bytes:
def _load_split_file(
self,
basename: str,
open_f: Optional[Callable[[str], BinaryIO]] = None,
) -> bytes:
file: List[bytes] = []
for i in range(0, 999):
for i in range(0, 1000):
item = f"{basename}.split{i}"
if self.fs.exists(item):
if open_f is not None:
try:
f = open_f(item)
except (FileNotFoundError, KeyError):
if i:
break
continue
with f:
file.append(f.read())
elif self.fs.exists(item):
with self.fs.open(item, "rb") as f:
file.append(f.read()) # type: ignore
elif i:
Comment thread
GoJean marked this conversation as resolved.
Resolved
Expand Down Expand Up @@ -311,7 +324,7 @@ def load_assets(self, assets: List[str], open_f: Callable[[str], BinaryIO]):
continue

split_files.append(basepath)
data = self._load_split_file(basepath)
data = self._load_split_file(basepath, open_f)
path = basepath
else:
data = open_f(path)
Expand Down