Skip to content
Merged
Show file tree
Hide file tree
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
Binary file added testdata/concatenated.zip
Binary file not shown.
21 changes: 20 additions & 1 deletion ziplinter-python/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import ziplinter

def main():
print("{}", ziplinter.parse_file("../testdata/unix.zip"))
info = ziplinter.parse_file("../testdata/unix.zip")
assert info["comment"] == ""

# created using `cat utf8-infozip.zip time-infozip.zip >> concatenated.zip`
with open("../testdata/concatenated.zip", "rb") as f:
data = f.read()

info1 = ziplinter.parse_bytes(data)

start = 0
for r in info1["parsed_ranges"]:
if r["contains"] == "local file header":
start = int(r["start"])
break

assert start == 162

info2 = ziplinter.parse_bytes(data[:start])

assert info1 != info2

if __name__ == '__main__':
main()
152 changes: 152 additions & 0 deletions ziplinter/src/snapshots/ziplinter__test__concatenated.zip.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
source: ziplinter/src/lib.rs
expression: result
---
{
"comment": "",
"contents": [
{
"central": {
"comment": "",
"compressed_size": 0,
"crc32": 0,
"creator_version": {
"host_system": "Unix",
"version": 30
},
"disk_nbr_start": 0,
"external_attrs": 2175008768,
"extra": [
85,
84,
5,
0,
3,
141,
73,
249,
89,
117,
120,
11,
0,
1,
4,
232,
3,
0,
0,
4,
232,
3,
0,
0
],
"flags": 0,
"header_offset": 0,
"internal_attrs": 0,
"method": "Store",
"mode": 420,
"modified": "2017-11-01T04:11:57Z",
"name": "test.txt",
"reader_version": {
"host_system": "MsDos",
"version": 10
},
"uncompressed_size": 0
},
"local": {
"accessed": null,
"compressed_size": 0,
"crc32": 0,
"created": null,
"extra": [
85,
84,
9,
0,
3,
141,
73,
249,
89,
141,
73,
249,
89,
117,
120,
11,
0,
1,
4,
232,
3,
0,
0,
4,
232,
3,
0,
0
],
"flags": 0,
"gid": 1000,
"header_offset": 0,
"method": "Store",
"method_specific": "None",
"mode": 0,
"modified": "2017-11-01T04:11:57Z",
"name": "test.txt",
"reader_version": {
"host_system": "MsDos",
"version": 10
},
"uid": 1000,
"uncompressed_size": 0
}
}
],
"encoding": "Utf8",
"eocd": {
"dir": {
"inner": {
"dir_disk_nbr": 0,
"dir_records_this_disk": 1,
"directory_offset": 228,
"directory_records": 1,
"directory_size": 78,
"disk_nbr": 0
},
"offset": 306
},
"dir64": null,
"global_offset": 162
},
"parsed_ranges": [
{
"contains": "end of central directory record",
"end": 328,
"start": 306
},
{
"contains": "central directory header",
"end": 306,
"filename": "test.txt",
"start": 228
},
{
"contains": "local file header",
"end": 228,
"filename": "test.txt",
"start": 162
},
{
"contains": "file data",
"end": 228,
"filename": "test.txt",
"start": 228
}
],
"size": 328
}