std.zip size limit of 2 GB?

Andre Pany andre at s-e-a-p.de
Thu Feb 15 11:56:04 UTC 2018


Hi,

I just noticed that std.zip will throw an exception if the source 
files exceeds 2 GB.
I am not sure whether this is a limitation of zip version 20 or a 
bug. On wikipedia a
size limit of 4 GB is mentioned. Should I open an issue?

Windows 10 with x86_64 architecture.

core.exception.RangeError at 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)
                 continue;

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

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

Kind regards
André


More information about the Digitalmars-d-learn mailing list