std.tar: trim also spaces from the beginning of file size

This commit is contained in:
Maciej 'vesim' Kuliński 2023-11-20 11:50:14 +01:00 committed by Andrew Kelley
parent 8ca4a5240e
commit f64f3423e4

View File

@ -82,7 +82,7 @@ pub const Header = struct {
pub fn fileSize(header: Header) !u64 {
const raw = header.bytes[124..][0..12];
const ltrimmed = std.mem.trimLeft(u8, raw, "0");
const ltrimmed = std.mem.trimLeft(u8, raw, "0 ");
const rtrimmed = std.mem.trimRight(u8, ltrimmed, " \x00");
if (rtrimmed.len == 0) return 0;
return std.fmt.parseInt(u64, rtrimmed, 8);