Skip to content

std.tar.pipeToFileSystem output the file data in wrong format #15222

Closed

Description

@Rishab49

Zig Version

0.11.0-dev.2399+d92b5fcfb

Steps to Reproduce and Observed Behavior

  1. create a zig file with following code
const std = @import("std");

pub fn main() !void {
    const allocator = std.heap.c_allocator;
    // Open the file
    var handle = try std.fs.cwd().openFile("yargs.tgz", .{});
    defer handle.close();

    // Create a decompresser
    var decompresser = try std.compress.gzip.decompress(allocator, handle.reader());
    defer decompresser.deinit();

    // Untar the archive using the decompresser
    try std.tar.pipeToFileSystem(std.fs.cwd(), decompresser.reader(), .{ .mode_mode = .ignore });
}
  1. download the tgz file from here https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz
  2. run the code

on running I am getting the following error

error: InvalidCharacter
C:\zig\lib\std\fmt.zig:1927:17: 0x7ff61f39dfd1 in charToDigit (tar.exe.obj)
        else => return error.InvalidCharacter,
                ^
C:\zig\lib\std\fmt.zig:1855:23: 0x7ff61f364614 in parseWithSign__anon_4751 (tar.exe.obj)
        const digit = try charToDigit(c, buf_radix);
                      ^
C:\zig\lib\std\fmt.zig:1754:5: 0x7ff61f356e17 in parseInt__anon_3977 (tar.exe.obj)
    return parseWithSign(T, buf, radix, .Pos);
    ^
C:\zig\lib\std\tar.zig:40:9: 0x7ff61f3566d6 in fileSize (tar.exe.obj)
        return std.fmt.parseInt(u64, rtrimmed, 8);
        ^
C:\zig\lib\std\tar.zig:117:27: 0x7ff61f3581bf in pipeToFileSystem__anon_3818 (tar.exe.obj)
        const file_size = try header.fileSize();
                          ^
D:\zig\unzipping\tar.zig:14:5: 0x7ff61f3598aa in main (tar.exe.obj)
    try std.tar.pipeToFileSystem(std.fs.cwd(), decompresser.reader(), .{ .mode_mode = .ignore });

Expected Behavior

It is expected that we have an decompressed folder with all of the files

Activity

  1. added
    bug
    on Apr 9, 2023
  2. added a commit that references this issue on Apr 9, 2023
    f990bd1
  3. added
    contributor friendly
    standard library
    on Apr 10, 2023
  4. added this to the 0.11.0 milestone on Apr 10, 2023
  5. added a commit that references this issue on Apr 23, 2023
    40029d6
  6. added a commit that references this issue on Apr 24, 2023
    2b5e448
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcontributor friendlystandard library

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions