const Attribute = struct kind: PaxAttributeKindlen: usizereader: *Io.Reader510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527 const Attribute = struct {
kind: PaxAttributeKind,
len: usize, // length of the attribute value
reader: *Io.Reader, // reader positioned at value start
// Copies pax attribute value into destination buffer.
// Must be called with destination buffer of size at least Attribute.len.
pub fn value(self: Attribute, dst: []u8) ![]const u8 {
if (self.len > dst.len) return error.TarInsufficientBuffer;
// assert(self.len <= dst.len);
const buf = dst[0..self.len];
const n = try self.reader.readSliceShort(buf);
if (n < self.len) return error.UnexpectedEndOfStream;
try validateAttributeEnding(self.reader);
if (hasNull(buf)) return error.PaxNullInValue;
return buf;
}
}