authorgravatar for twostepted@gmail.comTravis Staloch <twostepted@gmail.com> 2023-04-09 16:05:17-07:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-04-23 20:39:28+03:00
log40029d6875ce297406b573d78d11b0d00107cab6
treeaaf8efc5751477d0a62d23879e5be13241837a70
parent284c7b22a85a6a915740be826e66f91a4cbc743e

std.tar: make sub dirs + trim spaces

closes #15222. these changes allow the .tgz from this issue to decompress and the test code to succeed.

1 files changed, 5 insertions(+), 2 deletions(-)

lib/std/tar.zig+5-2
......@@ -35,7 +35,7 @@ pub const Header = struct {
3535 pub fn fileSize(header: Header) !u64 {
3636 const raw = header.bytes[124..][0..12];
3737 const ltrimmed = std.mem.trimLeft(u8, raw, "0");
38 const rtrimmed = std.mem.trimRight(u8, ltrimmed, "\x00");
38 const rtrimmed = std.mem.trimRight(u8, ltrimmed, " \x00");
3939 if (rtrimmed.len == 0) return 0;
4040 return std.fmt.parseInt(u64, rtrimmed, 8);
4141 }
......@@ -122,13 +122,16 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
122122 .directory => {
123123 const file_name = try stripComponents(unstripped_file_name, options.strip_components);
124124 if (file_name.len != 0) {
125 try dir.makeDir(file_name);
125 try dir.makePath(file_name);
126126 }
127127 },
128128 .normal => {
129129 if (file_size == 0 and unstripped_file_name.len == 0) return;
130130 const file_name = try stripComponents(unstripped_file_name, options.strip_components);
131131
132 if (std.fs.path.dirname(file_name)) |dir_name| {
133 try dir.makePath(dir_name);
134 }
132135 var file = try dir.createFile(file_name, .{});
133136 defer file.close();
134137