D: how to extract data from archive? -


i have simple code should extract data archive:

import std.stdio; import std.string; import std.file; import std.algorithm; import std.zip;  void main() {     string ar = `d:\ftp\s2-imfset_2015\ifpet-150101.zip`;     auto zip = new ziparchive(ar.read);     foreach(archivemember am; zip.directory)     {         writeln(am.expandeddata);     } } 

(thanks explaining each , map difference). when run it's print [] on console.

you need call zip.expand(am) before expanded data available. can name , size of archive member before expanding it.

import std.stdio; import std.string; import std.file; import std.algorithm; import std.zip;  void main() {     string ar = `d:\ftp\s2-imfset_2015\ifpet-150101.zip`;     auto zip = new ziparchive(ar.read);     foreach(name, am; zip.directory)     {         if(!am.expandedsize) continue; // ignore empty files         zip.expand(am);         writeln(am.expandeddata);     } } 

Comments

Popular posts from this blog

How to group boxplot outliers in gnuplot -

cakephp - simple blog with croogo -

bash - Performing variable substitution in a string -