| Thread overview | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
July 19, 2014 std.zip and a large archive | ||||
|---|---|---|---|---|
| ||||
I process archive:
///////////////
import std.stdio, std.zip, std.file;
int main()
{
auto zip = new ZipArchive(read("c:/test.zip"));
foreach (item; zip.directory) {
writeln("processing ", item.name, " ...");
// processing item...
}
return 0;
}
/////////////////
it works well for normal archives.
but how to process zip archive ~1GB ?
it takes a long of RAM.
| ||||
July 19, 2014 Re: std.zip and a large archive | ||||
|---|---|---|---|---|
| ||||
Posted in reply to AntonSotov | On Saturday, 19 July 2014 at 07:55:10 UTC, AntonSotov wrote:
> I process archive:
> ///////////////
> import std.stdio, std.zip, std.file;
>
> int main()
> {
> auto zip = new ZipArchive(read("c:/test.zip"));
> foreach (item; zip.directory) {
> writeln("processing ", item.name, " ...");
> // processing item...
> }
> return 0;
> }
> /////////////////
> it works well for normal archives.
> but how to process zip archive ~1GB ?
> it takes a long of RAM.
Hmm... it's unfortunate that ZipArchive doesn't take a file descriptor. As a workaround, you can use memory mapping:
import std.stdio, std.zip, std.file, std.mmfile;
int main()
{
auto mmfile = new MmFile(File("c:/test.zip", "rb"));
auto zip = new ZipArchive(mmfile[]);
foreach (item; zip.directory) {
writeln("processing ", item.name, " ...");
// processing item...
}
return 0;
}
| |||
July 19, 2014 Re: std.zip and a large archive | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | On Saturday, 19 July 2014 at 10:46:31 UTC, Marc Schütz wrote:
> Hmm... it's unfortunate that ZipArchive doesn't take a file descriptor. As a workaround, you can use memory mapping:
auto mmfile = new MmFile("c:/test.zip");
Thank you. it works!
| |||
July 19, 2014 Re: std.zip and a large archive | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | Marc Schütz:
> import std.stdio, std.zip, std.file, std.mmfile;
>
> int main()
> {
> auto mmfile = new MmFile(File("c:/test.zip", "rb"));
> auto zip = new ZipArchive(mmfile[]);
> foreach (item; zip.directory) {
> writeln("processing ", item.name, " ...");
> // processing item...
> }
> return 0;
> }
This could be added to the ZipArchive online docs.
Bye,
bearophile
| |||
July 19, 2014 Re: std.zip and a large archive | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | It seems that ti only works for zip files with less than 65000 entries, zip64 that allow read more than that do seem to be implemented. | |||
July 19, 2014 Re: std.zip and a large archive (spell fix) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Domingo Alvarez Duarte | It seems that this only works for zip files with less than 65000 entries, zip64 that allow read more than that do not seem to be implemented. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply