@@ -752,12 +752,14 @@ const FileType = enum {
752
752
tar ,
753
753
@"tar.gz" ,
754
754
@"tar.xz" ,
755
+ @"tar.zst" ,
755
756
git_pack ,
756
757
757
758
fn fromPath (file_path : []const u8 ) ? FileType {
758
759
if (ascii .endsWithIgnoreCase (file_path , ".tar" )) return .tar ;
759
760
if (ascii .endsWithIgnoreCase (file_path , ".tar.gz" )) return .@"tar.gz" ;
760
761
if (ascii .endsWithIgnoreCase (file_path , ".tar.xz" )) return .@"tar.xz" ;
762
+ if (ascii .endsWithIgnoreCase (file_path , ".tar.zst" )) return .@"tar.zst" ;
761
763
return null ;
762
764
}
763
765
@@ -1015,6 +1017,7 @@ fn unpackResource(
1015
1017
.tar = > try unpackTarball (f , tmp_directory .handle , resource .reader ()),
1016
1018
.@"tar.gz" = > try unpackTarballCompressed (f , tmp_directory .handle , resource , std .compress .gzip ),
1017
1019
.@"tar.xz" = > try unpackTarballCompressed (f , tmp_directory .handle , resource , std .compress .xz ),
1020
+ .@"tar.zst" = > try unpackTarballCompressed (f , tmp_directory .handle , resource , ZstdWrapper ),
1018
1021
.git_pack = > unpackGitPack (f , tmp_directory .handle , resource ) catch | err | switch (err ) {
1019
1022
error .FetchFailed = > return error .FetchFailed ,
1020
1023
error .OutOfMemory = > return error .OutOfMemory ,
@@ -1026,6 +1029,18 @@ fn unpackResource(
1026
1029
}
1027
1030
}
1028
1031
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
+
1029
1044
fn unpackTarballCompressed (
1030
1045
f : * Fetch ,
1031
1046
out_dir : fs.Dir ,
0 commit comments