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 › getFilename Public Function getFilename Doc Source Public Function std.zip.Iterator.Entry.getFilename
pub fn getFilename (self : Entry , stream : *File .Reader , filename_buf : []u8 , options : ExtractOptions ) ![]u8 Params File zip.zig: 416
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440 pub fn getFilename (self : Entry , stream : *File .Reader , filename_buf : []u8 , options : ExtractOptions ) ![]u8 {
if (filename_buf .len < self .filename_len )
return error .ZipInsufficientBuffer ;
switch (self .compression_method ) {
.store , .deflate => {},
else => return error .UnsupportedCompressionMethod ,
}
const filename = filename_buf [0 ..self .filename_len ];
{
try stream .seekTo (self .header_zip_offset + @sizeOf (CentralDirectoryFileHeader ));
try stream .interface .readSliceAll (filename );
}
if (options .allow_backslashes ) {
std .mem .replaceScalar (u8 , filename , '\\' , '/' );
} else {
if (std .mem .findScalar (u8 , filename , '\\' )) |_ |
return error .ZipFilenameHasBackslash ;
}
if (isBadFilename (filename ))
return error .ZipBadFilename ;
return filename ;
}