Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lower-level reading functions #68

Merged
merged 1 commit into from
Aug 29, 2024
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ZipArchives"
uuid = "49080126-0e18-4c2a-b176-c102e4b3760c"
authors = ["nhz2 <[email protected]>"]
version = "2.1.7"
version = "2.2.0"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
5 changes: 4 additions & 1 deletion src/ZipArchives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ include("types.jl")

include("reader.jl")
export ZipReader
export ZipBufferReader
export ZipBufferReader # alias for ZipReader for compat reasons

export zip_crc32

Expand All @@ -76,6 +76,9 @@ export zip_isdir
export zip_isexecutablefile
export zip_findlast_entry
export zip_comment
export zip_compression_method
export zip_general_purpose_bit_flag
export zip_entry_data_offset

export zip_test_entry
export zip_openentry
Expand Down
10 changes: 10 additions & 0 deletions src/reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ Note: if the zip file was corrupted, this might be wrong.
"""
zip_compression_method(x::HasEntries, i::Integer)::UInt16 = x.entries[i].method

"""
zip_general_purpose_bit_flag(x::HasEntries, i::Integer)::UInt16

Return the general purpose bit flag for entry `i`.

See https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
for a description of the bits.
"""
zip_general_purpose_bit_flag(x::HasEntries, i::Integer)::UInt16 = x.entries[i].bit_flags

"""
zip_iscompressed(x::HasEntries, i::Integer)::Bool

Expand Down
11 changes: 7 additions & 4 deletions test/test_reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ end
@test_throws ArgumentError("invalid compression method: 14. Only Store(0) and Deflate(8) supported for now") zip_openentry(r, 1)
@test zip_iscompressed(r, 1)
@test zip_names(r) == ["lzma_data"]
@test ZipArchives.zip_compression_method(r, 1) === 0x000e
@test zip_compression_method(r, 1) === 0x000e
@test zip_general_purpose_bit_flag(r, 1) === 0x0002 # indicates
# an end-of-stream (EOS) marker is used to
# mark the end of the compressed data stream
entry_data_offset = 39
compressed_size = 34
@test ZipArchives.zip_entry_data_offset(r, 1) === Int64(entry_data_offset)
@test ZipArchives.zip_entry_data_offset(r, big(1)) === Int64(entry_data_offset)
@test ZipArchives.zip_compressed_size(r, 1) === UInt64(compressed_size)
@test zip_entry_data_offset(r, 1) === Int64(entry_data_offset)
@test zip_entry_data_offset(r, big(1)) === Int64(entry_data_offset)
@test zip_compressed_size(r, 1) === UInt64(compressed_size)
end

@testset "reading file with zip64 disk number" begin
Expand Down
Loading