Skip to content

Commit

Permalink
(archives) fixed cdrom.Iso.tree
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Nov 26, 2024
1 parent 6eb8efd commit c1d3ccb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bsp_tool/archives/cdrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,16 @@ def __init__(self):
self.path_table = list()

def __repr__(self) -> str:
return f'<Iso {self.pvd.name!r} {len(self.namelist())} files @ 0x{id(self):016X}>'
return f"<Iso {self.pvd.name!r} {len(self.namelist())} files @ 0x{id(self):016X}>"

def folder_records(self, search_folder: str) -> List[Directory]:
# NOTE: search_folder is case sensitive
# TEST: "" & "/" should both index root
# -- maybe also "." & "./"
# TODO: is it easier to walk the directory tree?
search_folder.replace("\\", "/")
if search_folder.startswith("./"):
search_folder = search_folder[2:]
search_folder = f"/{search_folder}/"
while "//" in search_folder: # eliminate double slashes
# NOTE: have to replace twice for root ("/")
Expand Down Expand Up @@ -399,8 +401,9 @@ def listdir(self, search_folder: str) -> List[str]:
records = self.folder_records(search_folder)
assert records[0].name == "."
assert records[1].name == ".."
# NOTE: we could add a "/" to the end of a name if it's not a file
return [f.name for f in records[2:]]
return [
f.name if f.is_file else f"{f.name}/"
for f in records[2:]]

def namelist(self) -> List[str]:
filenames = set()
Expand Down

0 comments on commit c1d3ccb

Please sign in to comment.