Skip to content

Commit f42c3fa

Browse files
committed
use which to find zstd
1 parent 47c36b0 commit f42c3fa

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

+stdlib/+fileio/extract_zstd.m

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,18 @@ function extract_zstd(archive, out_dir)
1010
end
1111

1212
import stdlib.fileio.expanduser
13+
import stdlib.fileio.which
1314

1415
archive = expanduser(archive);
1516

1617
assert(isfile(archive), "%s is not a file", archive)
1718

18-
[ret, ~] = system("zstd -h");
19-
if ret ~= 0
20-
if ismac
21-
msg = "brew install zstd";
22-
elseif isunix
23-
msg = "apt install zstd";
24-
elseif ispc
25-
msg = "https://github.com/facebook/zstd/releases and look for zstd-*-win64.zip";
26-
else
27-
msg = "https://github.com/facebook/zstd/releases";
28-
end
29-
error("stdlib:fileio:extract_zstd:EnvironmentError", "need to have Zstd installed: \n install zstd: \n %s", msg)
30-
end
19+
exe = which("zstd");
20+
assert(~isempty(exe), "need to have Zstd installed: https://github.com/facebook/zstd")
3121

3222
tar_arc = tempname;
3323

34-
ret = system("zstd -d " + archive + " -o " + tar_arc);
24+
ret = system(exe + " -d " + archive + " -o " + tar_arc);
3525
assert(ret == 0, "problem extracting %s", archive)
3626

3727
untar(tar_arc, out_dir)

0 commit comments

Comments
 (0)