Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.0.0 - Português


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, ... where key1, 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.

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 — Fornece informações sobre um arquivo
  • fileparts — returns the path, filename and extension for a file path
  • save — Saves some chosen variables in a binary data file
Report an issue
<< Paths - Filenames Arquivos : funções de Entrada/Saída decompress >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Oct 24 14:35:26 CEST 2023