compress
Compress files in an archive
Syntax
files = compress(archivename, inputs, <opt_args>)
Arguments
- files
String vector of file names that have been compressed in the archive.
- archivename
A string specifying the archive path and name that will be created.
- inputs
String matrix of file names or folders that will be package and compress. When a folder is given, the content will be added recursively. Values can contain wildcards like
*.sci
- <opt_args>
This represents a sequence of statements
key1=value1, key2=value2, ...
wherekey1
,key2
, ... can be one of the following:- format
A string with one of the following values: zip, tar, 7zip, tar_ustar, tar_pax_interchange, tar_pax_restricted, tar_gnutar, raw.
- compression
A string with one of the following values: none, gzip, lzma, xz.
- level
A constant with a value between 0 and 9.
- password
The password string is used to encrypt the archive.
This option is only available for ZIP files.
Description
compress
creates a compressed archive that contains the given files and folders.
It uses the archive extension to apply default format and compression when no options are given.
Examples
// create a ZIP with fileio tests filesin = compress("TMPDIR/fileio_tests.zip", "SCI/modules/fileio/tests/unit_tests/*.tst") filesout = decompress("TMPDIR/fileio_tests.zip", "TMPDIR/fileio_tests") [p, fname, ext] = fileparts(filesout); assert_checkequal(filesin, fname+ext); // create a tar.xz with single file r100 = rand(100,100); save("TMPDIR/rand100.sod", "r100"); // low level compression compress("TMPDIR/rand100.tar.xz", "TMPDIR/rand100.sod", format="tar", compression="xz", level=0); // high level compression compress("TMPDIR/rand100l9.tar.xz", "TMPDIR/rand100.sod", format="tar", compression="xz", level=9); filesize = fileinfo("TMPDIR/rand100.sod")(1); l0size = fileinfo("TMPDIR/rand100.tar.xz")(1); l9size = fileinfo("TMPDIR/rand100l9.tar.xz")(1); disp("size of rand100.sod: " + string(filesize)) disp("size of rand100.tar.xz: " + string(l0size)) disp("size of rand100l9.tar.xz: " + string(l9size))
See also
- decompress — decompress files from an archive
- fileinfo — ファイルに関する情報を出力
- fileparts — ファイルパスのパス,ファイル名,拡張子を返す
- save — Saves some chosen variables in a binary data file
Report an issue | ||
<< Paths - Filenames | Files : Input/Output functions | decompress >> |