@@ -752,12 +752,14 @@ const FileType = enum {
752752 tar ,
753753 @"tar.gz" ,
754754 @"tar.xz" ,
755+ @"tar.zst" ,
755756 git_pack ,
756757
757758 fn fromPath (file_path : []const u8 ) ? FileType {
758759 if (ascii .endsWithIgnoreCase (file_path , ".tar" )) return .tar ;
759760 if (ascii .endsWithIgnoreCase (file_path , ".tar.gz" )) return .@"tar.gz" ;
760761 if (ascii .endsWithIgnoreCase (file_path , ".tar.xz" )) return .@"tar.xz" ;
762+ if (ascii .endsWithIgnoreCase (file_path , ".tar.zst" )) return .@"tar.zst" ;
761763 return null ;
762764 }
763765
@@ -1015,6 +1017,7 @@ fn unpackResource(
10151017 .tar = > try unpackTarball (f , tmp_directory .handle , resource .reader ()),
10161018 .@"tar.gz" = > try unpackTarballCompressed (f , tmp_directory .handle , resource , std .compress .gzip ),
10171019 .@"tar.xz" = > try unpackTarballCompressed (f , tmp_directory .handle , resource , std .compress .xz ),
1020+ .@"tar.zst" = > try unpackTarballCompressed (f , tmp_directory .handle , resource , ZstdWrapper ),
10181021 .git_pack = > unpackGitPack (f , tmp_directory .handle , resource ) catch | err | switch (err ) {
10191022 error .FetchFailed = > return error .FetchFailed ,
10201023 error .OutOfMemory = > return error .OutOfMemory ,
@@ -1026,6 +1029,18 @@ fn unpackResource(
10261029 }
10271030}
10281031
1032+ // due to slight differences in the API of std.compress.(gzip|xz) and std.compress.zstd, zstd is
1033+ // wrapped for generic use in unpackTarballCompressed: see github.com/ziglang/zig/issues/14739
1034+ const ZstdWrapper = struct {
1035+ fn DecompressType (comptime T : type ) type {
1036+ return error {}! std .compress .zstd .DecompressStream (T , .{});
1037+ }
1038+
1039+ fn decompress (allocator : Allocator , reader : anytype ) DecompressType (@TypeOf (reader )) {
1040+ return std .compress .zstd .decompressStream (allocator , reader );
1041+ }
1042+ };
1043+
10291044fn unpackTarballCompressed (
10301045 f : * Fetch ,
10311046 out_dir : fs.Dir ,
0 commit comments