Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › zip › Iterator › Entry › extract Public Function extract Doc Source Public Function std.zip.Iterator.Entry.extract
pub fn extract (
self : Entry ,
stream : *File .Reader ,
options : ExtractOptions ,
filename_buf : []u8 ,
dest : Io .Dir ,
) !void Params File zip.zig: 539
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576 pub fn extract (
self : Entry ,
stream : *File .Reader ,
options : ExtractOptions ,
filename_buf : []u8 ,
dest : Io .Dir ,
) !void {
const io = stream .io ;
const filename = try self .getFilename (stream , filename_buf , options );
// All entries that end in '/' are directories
if (filename [filename .len - 1 ] == '/' ) {
if (self .uncompressed_size != 0 )
return error .ZipBadDirectorySize ;
try dest .createDirPath (io , filename [0 .. filename .len - 1 ]);
return ;
}
const out_file = blk : {
if (std .fs .path .dirname (filename )) |dirname | {
var parent_dir = try dest .createDirPathOpen (io , dirname , .{});
defer parent_dir .close (io );
const basename = std .fs .path .basename (filename );
break :blk try parent_dir .createFile (io , basename , .{ .exclusive = true });
}
break :blk try dest .createFile (io , filename , .{ .exclusive = true });
};
defer out_file .close (io );
var out_file_buffer : [1024 ]u8 = undefined ;
var file_writer = out_file .writer (io , &out_file_buffer );
self .extractTo (stream , &file_writer .interface ) catch |err | switch (err ) {
error .WriteFailed => |e | return file_writer .err orelse e ,
else => return err ,
};
try file_writer .end ();
}