Skip to content

Change DOS date from 0x0000 to 0x0021 #47

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

Merged
merged 4 commits into from
Apr 11, 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Currently ZipArchives has the following benefits over ZipFile:
6. Ability to append to an existing zip archive, in an `IO` or in a file on disk.

ZipArchives currently has the following limitations compared to ZipFile:
1. No way to specify the modification time, times are set to zero dos time.
1. No way to specify the modification time, times are set to 1980-01-01 00:00:00 DOS date time.
2. No `flush` function for `ZipWriter`. `close` and `zip_append_archive` can be used instead.
3. Requires at least Julia 1.6.
4. No way to read an archive from an `IOStream`, `mmap` can be used instead.
Expand Down
1 change: 0 additions & 1 deletion src/reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ function zip_openentry(r::ZipReader, i::Int)
@argcheck entry_data_offset ≤ fsize - compressed_size

@argcheck read(io, local_name_len) == view(r.central_dir_buffer, entry.name_range)
skip(io, extra_len)

begin_ind::Int64 = firstindex(r.buffer)
startidx = begin_ind + entry_data_offset
Expand Down
4 changes: 2 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Base.@kwdef mutable struct PartialEntry
comment::String = ""
external_attrs::UInt32 = UInt32(0o0100644)<<16 # external file attributes: https://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute
method::UInt16 = Store # compression method
dos_time::UInt16 = 0 # last mod file time
dos_date::UInt16 = 0 # last mod file date
dos_time::UInt16 = 0x0000 # last mod file time
dos_date::UInt16 = 0x0021 # last mod file date
force_zip64::Bool = false
offset::UInt64
bit_flags::UInt16 = 1<<11 # general purpose bit flag: 11 UTF-8 encoding
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Malt = "36869731-bdee-424d-aa32-cab38c994e3b"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
1 change: 0 additions & 1 deletion test/external_unzippers.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Used to test that zip files written by ZipArchives.jl can be read by other programs.
# This defines a vector of functions in `unzippers`
# These functions take a zipfile path and a directory path and extract the zipfile into the directory
import ZipFile
import p7zip_jll
# ENV["JULIA_CONDAPKG_BACKEND"] = "Null"
try
Expand Down
60 changes: 60 additions & 0 deletions test/test_writer.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include("common.jl")
using CodecZlib: GzipCompressorStream, GzipDecompressorStream
using OffsetArrays: Origin
import Malt
import ZipFile

Debug = false
tmp = mktempdir()
Expand Down Expand Up @@ -121,6 +123,64 @@ include("external_unzippers.jl")
end
end

if VERSION ≥ v"1.7.0" # ZipStreams requires julia 1.7
@testset "Writer compat with ZipStreams" begin
# setup test env for ZipStreams
worker = Malt.Worker()
Malt.remote_eval_fetch(worker, quote
import Pkg
Pkg.activate(;temp=true)
Pkg.add(name="ZipStreams", version="2.1.0")
import ZipStreams
nothing
end)
for filename in readdir(tmp)
endswith(filename, ".zip") || continue
zippath = joinpath(tmp, filename)
dir = ZipReader(read(zippath))
Malt.remote_eval_fetch(worker, quote
ZipStreams.zipsource($(zippath)) do zs
ZipStreams.validate(zs)
end
nothing
end)
Malt.remote_eval_fetch(worker, quote
zs = ZipStreams.zipsource($(zippath))
nothing
end)
for i in 1:zip_nentries(dir)
name, data = Malt.remote_eval_fetch(worker, quote
f = ZipStreams.next_file(zs)
(f.info.name, read(f,String))
end)
@test zip_readentry(dir, name, String) == data
end
@test Malt.remote_eval_fetch(worker, quote
f = ZipStreams.next_file(zs)
isnothing(f)
end)
Malt.remote_eval_fetch(worker, quote
close(zs)
nothing
end)
end
end
end

@testset "Writer compat with ZipFile" begin
for filename in readdir(tmp)
endswith(filename, ".zip") || continue
zippath = joinpath(tmp, filename)
dir = ZipReader(read(zippath))
r = ZipFile.Reader(zippath)
for f in r.files
@test zip_readentry(dir, f.name, String) == read(f, String)
end
@test length(r.files) == zip_nentries(dir)
close(r)
end
end

if !Debug
rm(tmp, recursive=true)
end
Expand Down
Loading