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

Another fix handling of UTF-8 filenames

Open nhz2 opened this issue 2 years ago • 0 comments

Fixes #84

This PR continues on the work of @cerisola in #85 And incorporates requested changes from @fhs

I have added os :: UInt8 and externalattrs :: UInt32 fields to both ReadableFile and WritableFile. As noted in #85, these need to be modified from zero to get proper UTF-8 support.

I am setting os to 0x03 and externalattrs to UInt32(UInt32(0o0100644) << 16) by default in addfile. This will mark files as mode 0o644

https://github.com/madler/zipflow/blob/2bef2123ebe519c17b18d2d0c3c71065088de952/zipflow.c#L752 also adds the 0o0100000 to specify the file is a regular file, as described in https://unix.stackexchange.com/a/14727

This default mode also matches the Tar.jl default: https://github.com/JuliaIO/Tar.jl#permissions

To get back the previous behavior, do for example f = ZipFile.addfile(w, "julia.txt"; os=0x00, externalattrs=0x00000000)

nhz2 avatar Apr 30 '23 16:04 nhz2