[Issue 1832] New: reading/writing an archive causes data loss; std.zip horribly broken
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 13 17:09:14 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1832
Summary: reading/writing an archive causes data loss; std.zip
horribly broken
Product: D
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: critical
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: default_357-line at yahoo.de
Consider, if you will, the following source.
import std.zip, std.file;
void main() {
auto arch = new ZipArchive;
auto test = new ArchiveMember;
test.name = "foob";
test.expandedData = [cast(ubyte) 2, 3, 4, 5];
arch.addMember(test);
auto data = arch.build;
write("test.zip", data);
auto arch2 = new ZipArchive(data);
// arch2.expand(arch2.directory["foob"]); // this fixes it
auto data2 = arch2.build;
write("test2.zip", data2); // test2.zip contains a single file, "foob", zero
bytes. It's horribly empty in there.
}
It seems when Phobos builds the archive data without decompressing in-between,
it doesn't consider the already existing compressed data to be of any
particular relevance and just recompresses the (empty) uncompressed data.
This bug just cost me two days of work. Glee!
--feep
--
More information about the Digitalmars-d-bugs
mailing list