Skip to content

Commit

Permalink
Add get_dol() to FileProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquegemignani committed Dec 20, 2022
1 parent c90210a commit 86975eb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions retro_data_structures/asset_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def rglob(self, pattern: str) -> Iterator[str]:
def open_binary(self, name: str) -> typing.BinaryIO:
raise NotImplementedError()

def get_dol(self) -> bytes:
raise NotImplementedError()


class PathFileProvider(FileProvider):
def __init__(self, root: Path):
Expand All @@ -51,6 +54,10 @@ def rglob(self, name: str) -> Iterator[str]:
def open_binary(self, name: str) -> typing.BinaryIO:
return self.root.joinpath(name).open("rb")

def get_dol(self) -> bytes:
with self.open_binary("sys/main.dol") as f:
return f.read()


class IsoFileProvider(FileProvider):
def __init__(self, iso_path: Path):
Expand Down Expand Up @@ -80,6 +87,9 @@ def rglob(self, pattern: str) -> Iterator[str]:
def open_binary(self, name: str):
return self.data.read_file(name)

def get_dol(self) -> bytes:
return self.data.get_dol()


class AssetManager:
"""
Expand Down

0 comments on commit 86975eb

Please sign in to comment.