std.zip size limit of 2 GB?
Steven Schveighoffer
schveiguy at yahoo.com
Thu Feb 15 18:49:55 UTC 2018
On 2/15/18 6:56 AM, Andre Pany wrote:
> 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é
I think it's inherent in the zlib API. I haven't used all of the
library, but the portion I did use (using zstream) uses uint for buffer
sizes.
-Steve
More information about the Digitalmars-d-learn
mailing list