Skip to content

Commit 038850f

Browse files
authored
Improve docs (#100)
1 parent c3aaa44 commit 038850f

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

src/reader.jl

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,30 @@ function zip_test(r::ZipReader)::Nothing
310310
end
311311

312312
"""
313-
zip_openentry(r::ZipReader, i::Union{AbstractString, Integer})
313+
zip_openentry(r::ZipReader, i::Union{AbstractString, Integer})::IO
314314
zip_openentry(f::Function, r::ZipReader, i::Union{AbstractString, Integer})
315315
316316
Open entry `i` from `r` as a readable IO.
317317
318318
If `i` is a string open the last entry with the exact matching name.
319319
320-
Make sure to close the returned stream when done reading,
321-
if not using the do block method.
320+
# Usage
321+
322+
Close the returned stream when done, or use the `do`-block form which closes it:
323+
324+
```julia
325+
io = zip_openentry(r, "file.txt")
326+
nlines = try
327+
countlines(io)
328+
finally
329+
close(io)
330+
end
331+
332+
nlines = zip_openentry(r, "file.txt") do io
333+
countlines(io)
334+
end
335+
# `io` closed automatically
336+
```
322337
323338
The stream returned by this function
324339
should only be accessed by one thread at a time.
@@ -751,14 +766,25 @@ number of entries in the archive.
751766
752767
`zip_names(r::ZipReader)::Vector{String}` returns the names of all the entries in the archive.
753768
754-
The following get information about an entry in the archive:
769+
The following functions get information about an entry in the archive:
755770
756771
Entries are indexed from `1:zip_nentries(r)`
757772
758-
1. `zip_name(r::ZipReader, i::Integer)::String`
759-
1. `zip_uncompressed_size(r::ZipReader, i::Integer)::UInt64`
760-
761-
`zip_test_entry(r::ZipReader, i::Integer)::Nothing` checks if an entry is valid and has a good checksum.
773+
1. `zip_name(r, i)::String`
774+
1. `zip_readentry(r, i)::Vector{UInt8}`
775+
1. `zip_isdir(r, i)::Bool`
776+
1. `zip_uncompressed_size(r, i)::UInt64`
777+
1. `zip_compressed_size(r, i)::UInt64`
778+
1. `zip_compression_method(r, i)::UInt16`
779+
1. `zip_entry_data_offset(r, i)::Int64`
780+
1. `zip_stored_crc32(r, i)::UInt32`
781+
1. `zip_comment(r, i)::String`
782+
1. `zip_isexecutablefile(r, i)::Bool`
783+
1. `zip_definitely_utf8(r, i)::Bool`
784+
1. `zip_iscompressed(r, i)::Bool`
785+
1. `zip_general_purpose_bit_flag(r, i)::UInt16`
786+
787+
`zip_test_entry(r::ZipReader, i::Integer)::Nothing` will throw an error if an entry is invalid or has a bad checksum.
762788
763789
`zip_openentry` and `zip_readentry` can be used to read data from an entry.
764790

0 commit comments

Comments
 (0)