ZipFile.jl icon indicating copy to clipboard operation
ZipFile.jl copied to clipboard

File Position limited to UInt32 ?

Open ThummeTo opened this issue 2 years ago • 3 comments

When adding many larger files via addfile, I run into an exception:

ERROR: LoadError: InexactError: trunc(UInt32, 4320522198)
Stacktrace:
  [1] throw_inexacterror(f::Symbol, #unused#::Type{UInt32}, val::Int64)
    @ Core .\boot.jl:614
  [2] checked_trunc_uint
    @ .\boot.jl:644 [inlined]
  [3] toUInt32
    @ .\boot.jl:728 [inlined]
  [4] UInt32(x::Int64)
    @ Core .\boot.jl:768
  [5] addfile(w::ZipFile.Writer, name::String; method::UInt16, mtime::Float64)
    @ ZipFile C:\Users\thummeto\.julia\packages\ZipFile\6aqG6\src\ZipFile.jl:610

The corresponding codeline looks indeed like this:

f = WritableFile(w._io, name, UInt16(method), dostime, dosdate,
        UInt32(0), UInt32(0), UInt32(0), UInt32(position(w._io)),
        Int64(-1), w._io, false)

So position(w._io) is limited to UInt32. Is this a design limit or should it be possible to zip larger files?

Thanks and best regards!

ThummeTo avatar Nov 08 '22 09:11 ThummeTo

@ThummeTo I ran into the same issue trying to ZIP a large CSV (5+ GB). I've opened #99 that should hopefully fix it but I haven't tested it thoroughly. Would you be able to run it for your file? We can work together to increase support for larger files! CC: @fhs

ssingh13-rms avatar Apr 02 '23 13:04 ssingh13-rms

I can check that soon (best think would be to define a MWE that writes large nonsense-files). I don't know if it's at easy as replacing Uint32 with UInt64, propably there are limitations in the underlaying library to Int32 ... but why not try it like in your PR ...

ThummeTo avatar Apr 03 '23 06:04 ThummeTo

To save larger files, ZIP64 needs to be used, see https://en.wikipedia.org/wiki/ZIP_(file_format)#ZIP64

Just replacing the UInt32 with UInt64 won't work. #88 Added support for reading ZIP64, but not writing yet. So ZIP64 support for writing still needs to be worked on.

nhz2 avatar Apr 15 '23 21:04 nhz2