Skip to content

Commit

Permalink
Read file backwards to find enddir offset
Browse files Browse the repository at this point in the history
  • Loading branch information
fchorney authored and fhs committed Jan 18, 2020
1 parent e930d39 commit 0d09263
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ZipFile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function _find_enddiroffset(io::IO)
n = filesize-k
seek(io, n)
b = read!(io, Array{UInt8}(undef, k))
for i in 1:k-3
for i in k-3:-1:1
if getindex_u32le(b, i) == _EndCentralDirSig
offset = n+i-1
break
Expand Down
Binary file added test/EOCD.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function fileequals(f, s)
end

# test a zip file that contains multiple copies of the EOCD hex signature
# This test will fail
@test_broken ZipFile.Reader(joinpath(dirname(@__FILE__),"EOCD.zip"))
dir = ZipFile.Reader(joinpath(dirname(@__FILE__),"EOCD.zip"))
@test length(dir.files) == 1

# test a zip file created using Info-Zip
dir = ZipFile.Reader(joinpath(dirname(@__FILE__), "infozip.zip"))
Expand Down

0 comments on commit 0d09263

Please sign in to comment.