Skip to content

Instantly share code, notes, and snippets.

@scivision

scivision/extract_zstd.m

Last active Apr 20, 2021
Embed
What would you like to do?
Matlab extract .zst Zstd compressed files
function extract_zstd(archive, out_dir)
% extract a zstd file "archive" to "out_dir"
if ~isfile(archive)
error("%s is not a file", archive)
end
[ret, ~] = system("zstd -h");
if ret ~= 0
if ismac
msg = "brew install zstd";
elseif isunix
msg = "apt install zstd";
else
msg = "https://github.com/facebook/zstd/releases extract and put that directory on PATH";
end
error("need to have Zstd installed: \n install zstd by: \n %s", msg)
end
tar_arc = tempname;
ret = system("zstd -d " + archive + " -o " + tar_arc);
if ret ~= 0
error("problem extracting %s", archive)
end
untar(tar_arc, out_dir)
delete(tar_arc)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment