Thread overview |
---|
February 21, 2021 How add png image to zip file using std.zip? | ||||
---|---|---|---|---|
| ||||
ZipArchive zip = new ZipArchive(); std.file.write("foo.zip", zip.build()); ArchiveMember f = new ArchiveMember(); f.name = "Wallpaper_001.png"; zip.addMember(f); std.file.write("foo.zip", zip.build()); File is added with file size 0. How can I use expandedData for add images files? Or what I use for it? |
February 21, 2021 Re: How add png image to zip file using std.zip? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcone | On Sunday, 21 February 2021 at 17:17:56 UTC, Marcone wrote: > ZipArchive zip = new ZipArchive(); > std.file.write("foo.zip", zip.build()); > > ArchiveMember f = new ArchiveMember(); > f.name = "Wallpaper_001.png"; > > zip.addMember(f); > std.file.write("foo.zip", zip.build()); > > File is added with file size 0. > How can I use expandedData for add images files? Or what I use for it? expandedData should hold the contents of the uncompressed file, as byte array. So something like: f.name = "Wallpaper_001.png"; f.expandedData = cast(ubyte[])std.file.read("Wallpaper_001.png"); should work. f.name = "Wallpaper_001.png" only says "create a file named Wallpaper_001.png inside the zip". It doesn't say "put the Wallpaper_001.png file into the zip". |
February 22, 2021 Re: How add png image to zip file using std.zip? | ||||
---|---|---|---|---|
| ||||
Posted in reply to JN | On Sunday, 21 February 2021 at 18:10:43 UTC, JN wrote:
> On Sunday, 21 February 2021 at 17:17:56 UTC, Marcone wrote:
>> ZipArchive zip = new ZipArchive();
>> std.file.write("foo.zip", zip.build());
>>
>> ArchiveMember f = new ArchiveMember();
>> f.name = "Wallpaper_001.png";
>>
>> zip.addMember(f);
>> std.file.write("foo.zip", zip.build());
>>
>> File is added with file size 0.
>> How can I use expandedData for add images files? Or what I use for it?
>
> expandedData should hold the contents of the uncompressed file, as byte array. So something like:
>
> f.name = "Wallpaper_001.png";
> f.expandedData = cast(ubyte[])std.file.read("Wallpaper_001.png");
>
> should work. f.name = "Wallpaper_001.png" only says "create a file named Wallpaper_001.png inside the zip". It doesn't say "put the Wallpaper_001.png file into the zip".
Very good! Work very well. I was trying using rawRead. Now work fine.
|
Copyright © 1999-2021 by the D Language Foundation