Compression

Print Friendly, PDF & Email

◷ Reading Time: 2 minutes

FlexRule.Extensions.Compression

This extension enables compression capability for files and folders.

pack

Creates a package file containing all files within a folder

 pack (type, source, target)
  • type: zip, tgz, gz
  • source: source folder (zip, tgz) or file (gz) to create the package
  • target: target full file path to be created
  • Return: the created target package file

When the required target folder does not exist, it will be created automatically

Example 1: Packaging a folder to a zip file
pack('zip', 'd:\\sources\\samples', 'd:\\backup\\source-sample.zip')

unpack

Creates a folder and extract a package file

 unpack (type, source, target)
  • type: zip, tgz, gz
  • source: source file to be extracted
  • target: target folder (zip, tgz) or file (gz) to store the extracted file(s). GZ is only for a single file.
  • Return: the created target folder (zip, tgz) or file (gz)

When the required target folder does not exist, it will be created automatically

Example 1: Unpacking a GZ file
unpack('gz', 'd:\\temp\\myfile.csv.gz', 'd:\\temp\\myfile.csv')
Example 2: Unpacking a ZIP file
unpack('zip', 'd:\\temp\\archive1.zip', 'd:\\archive1')
Updated on July 9, 2019

Was this article helpful?

Related Articles