#how to use `std.zip` to list contents of Zip file

1 messages · Page 1 of 1 (latest)

left skiff
#

my code is based on the extract function at line 582 of zip.zig:

    const SeekableStream = @TypeOf(ss);
    var iter = try std.zip.Iterator(SeekableStream).init(ss);
    var diag: std.zip.Diagnostics = .{ .allocator = al };

    var filename_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
    while (try iter.next()) |entry| {
        try diag.nextFilename(filename_buf[0..entry.filename_len]);

        std.debug.print("filename: {s}\n", .{filename_buf[0..entry.filename_len]});
    }

but it outputs garbage:

filename: ����������������
filename: ���������������
filename: ����������������
filename: �����������������������������
filename: �����������������
filename: ���������������������������
filename: �����������������
filename: ���������������������

could it be that this filename data is not filled in unless extract has just been called? -:

#

how to use std.zip to list contents of Zip file

left skiff
#

OK i think it's not possible and is kind of an intended limitation of the api, but it seems to be based on std.tar which looks like it would be able to do this

gray mantle
#

yeah std.zip.Diagnostics are not implemented except for the root dir part which is used by the package manager

left skiff
#

Ah thanks. I wasn't sure whether to post a bug or feature request, or if I just didn't understand the code.

left skiff
pearl arch
#

This is simple but not finished implementation of zip, also not all algorithms are implemented yet

#

Test are not passing btw

left skiff
modest cobalt
#

lots of zip files packed in windows are not utf8

left skiff
left skiff
# pearl arch This is simple but not finished implementation of zip, also not all algorithms a...

what exactly is the relationship between this zig-archive and std.zig? Is one based on the other or are they independent? Is the one in std only intended to support a subset of zip functionality needed in the build process, and the std.tar for that matter? or will it/they grow to have full functionality? or is this zig-archive intended to be the full-functioned one separate from std? I see in the zip TODO it mentions tar archives? is it intended to cover both?
(also does this belong in #stdlib-devel?)

gray mantle
#

std.zip was merged only weeks ago as an initial implementation because I needed it for other development work, it will be improved whenever someone improves it and opens a PR