Skip to content

Commit

Permalink
(archives.nexon)(#198) closing notes on PakFile
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Sep 2, 2024
1 parent 6c067f2 commit 3e49c5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions bsp_tool/archives/nexon.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def from_stream(cls, stream: io.BytesIO) -> PakFile:
return out

def as_bytes(self):
# NOTE: decompresses all data
out = list()
# TODO: preserve local_files order (if unedited)
for local_file in self.local_files.values():
Expand Down
5 changes: 3 additions & 2 deletions tests/archives/nexon/test_PakFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
pakfiles = {
"empty": b"".join([ # just an EOCD
b"CS\x05\x06", b"\x00" * 16, b"\x01", b"\x00" * 4]),
# TODO: with a file
"deflate": b"".join([
"deflate": b"".join([ # 1 file, uncompressed
# LocalFile
b"CS\x03\x04",
b"\x00\x00", # unused
Expand Down Expand Up @@ -38,11 +37,13 @@
b"\x01\x00\x00\x00", # one
b"\x00"]) # unused
# TODO: with an LZMA compressed file
# NOTE: .as_bytes() cannot recompress yet, test will fail
}


@pytest.mark.parametrize("raw_pakfile", pakfiles.values(), ids=pakfiles.keys())
def test_from_bytes(raw_pakfile: bytes):
# NOTE: also tests as_bytes
pakfile = nexon.PakFile.from_bytes(raw_pakfile)
pakfile_bytes = pakfile.as_bytes()
# TODO: validate LocalFile.crc32
Expand Down

0 comments on commit 3e49c5b

Please sign in to comment.