Directories in zip
somebody at somewhere.com
Tue Dec 22 15:15:38 PST 2009
Ah, well, it seems simply putting the directory in the member.name (ie.
"dir\test.txt") is the way to do it.
Move along, nothing to see here.
"nobody" <somebody at somewhere.com> wrote in message
news:hggvh2$1t67$1 at digitalmars.com...
> (I'm using D1)
> Is it possible to create directories in a zip with std.zip? I couldn't
> find any info about that.
> So far I've only figured out how to read/write files. (code below)
> Or should I be using something else entirely if I want to create archives?
> module main;
> import std.stdio: writefln;
> import std.file: read, write;
> import std.zip;
> void main()
> auto archive = new ZipArchive;
> auto member = new ArchiveMember;
> member.compressionMethod = 8; //0: none, 8: deflate
> member.name = `hello.txt`;
> member.expandedData = cast(ubyte)`Hello`;
> member = new ArchiveMember;
> member.compressionMethod = 8;
> member.name = `world.txt`;
> member.expandedData = cast(ubyte)`World!`;
> auto data = archive.build();
> auto text = read(`test.zip`);
> auto archive2 = new ZipArchive(text);
> foreach (ArchiveMember mem; archive2.directory)
More information about the Digitalmars-d-learn