I am adding a compress method to the tar struct in the zig std library, just to see if I can and maybe get it merged eventually. Anyways, there is this Header struct, which is has a bytes field of type *const [SIZE]u8 and it is const because you don’t need to edit it for the already implemented extract method. The bytes correspond to an actual tar header in a tar archive, and has functions like this:
pub fn prefix(header: Header) []const u8 {
return header.str(345, 155);
}
Where there are the magic indices where the data is, and this is useful to keep these indices out of actual logic. Right now they are also returning []const u8 so it isn’t mutable.
Should I edit Header to be mutable, and have the functions return []u8 too, I just didn’t want to give the reading extract the []u8.
After writing, this actually sounds kind of stupid, just use mutable slices, but still, what are your thoughts?