std.zip for Binary example

Sean Campbell via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 17 02:43:55 PST 2016


On Sunday, 17 January 2016 at 10:34:19 UTC, locco wrote:
> Hi :)
> I found this example:
> ======================================================================
> import std.file: write;
> import std.string: representation;
> void main()
> {
>    char[] data = "Test data.\n".dup;
>    // Create an ArchiveMember for the test file.
>    ArchiveMember am = new ArchiveMember();
>    am.name = "test.txt";
>    am.expandedData(data.representation);
>    // Create an archive and add the member.
>    ZipArchive zip = new ZipArchive();
>    zip.addMember(am);
>    // Build the archive
>    void[] compressed_data = zip.build();
>    // Write to a file
>    write("test.zip", compressed_data);
> }
> ======================================================================
> But i cound't find example code for binary file.
> How can i make ArciveMember for binary file?


std.zip dosen't discriminate against text and binary files files.
p.s. remember to import std.zip



More information about the Digitalmars-d-learn mailing list