www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18452] New: std.zip has size limit of 2 GB


          Issue ID: 18452
           Summary: std.zip has size limit of 2 GB
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: andre s-e-a-p.de

I just noticed that std.zip will throw an exception if the source files exceeds
2 GB. It seems an issue with std.zip as zlib has a limit of 4 GB.

Windows 10 with x86_64 architecture.

core.exception.RangeError std\zip.d(808): Range violation
0x00007FF7C9B1705C in d_arrayboundsp
0x00007FF7C9B301FF in  safe void std.zip.ZipArchive.putUshort(int, ushort)
0x00007FF7C9B2E634 in void[] std.zip.ZipArchive.build()

    void zipFolder(string archiveFilePath, string folderPath)
        import std.zip, std.file;

        ZipArchive zip = new ZipArchive();
        string folderName = folderPath.baseName;

        foreach(entry; dirEntries(folderPath, SpanMode.depth))
            if (!entry.isFile)

            ArchiveMember am = new ArchiveMember();
            am.name = entry.name[folderPath.length + 1..$];
            am.expandedData(cast(ubyte[]) read(entry.name));

        void[] compressed_data = zip.build(); // zip.build() will throw
        write(archiveFilePath, compressed_data);

Comment from Steven Schveighoffer:
...And you are right. I looked into it a bit, this has nothing to do
(superficially) with zlib, it has to do with std.zip:


Really, i should be size_t in all places, I can't see why it should ever be

And Stefan Koch:
...It was partially changed in this PR:
The the put methods where left at int must have been an oversight.

https://forum.dlang.org/post/pkhmlemvrpkroiqhugmw forum.dlang.org

Feb 16 2018