Skip to content

Split file can't be loaded in the apk or zip. #397

Closed

Description

@GoJean

Bug
When we load a ZIP or APK file, The split file can't be loaded properly.Because it find file in the filesystem instead of the zip file with the path of zip.

Code
In the UnityPy/environment.py

def load_assets(self, assets: List[str], open_f: Callable[[str], BinaryIO]):
        """
        Load all assets from a list of files via the given open_f function.

        Parameters
        ----------
        assets : List[str]
            List of files to load.
        open_f : Callable[[str], io.IOBase]
            Function to open the files.
            The function takes a file path and returns an io.IOBase object.
        """
        split_files = []
        for path in assets:
            splitMatch = reSplit.match(path)
            if splitMatch:
                basepath, _basename = splitMatch.groups()

                if basepath in split_files:
                    continue

                split_files.append(basepath)
                data = self._load_split_file(basepath) # should pass the open_f!
                path = basepath
            else:
                data = open_f(path)
            self.load_file(data, name=path)
def _load_split_file(self, basename: str) -> bytes:
        file: List[bytes] = []
        for i in range(0, 999):
            item = f"{basename}.split{i}"
            if self.fs.exists(item):
                with self.fs.open(item, "rb") as f: # should use open_f!
                    file.append(f.read())  # type: ignore
            elif i:
                break
        return b"".join(file)

Activity

  1. added a commit that references this issue on Oct 31, 2026
    7b6b21e
  2. added a commit that references this issue on Nov 15, 2026
    0d7594d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions