FILE_UNZIP

The FILE_UNZIP procedure uncompresses ZIP files. The uncompression of individual files within the ZIP file is done using the ZLIB_UNCOMPRESS routine.

This routine is written in the IDL language. Its source code can be found in the file file_unzip.pro in the lib subdirectory of the IDL distribution.

Note: Because of IDL's file I/O limitations, the resulting files and directories will not have any of the original file owner information, permissions (file modes) or time stamps. Instead, the files and directories will have the current file owner and default permissions, and will have a time stamp equal to the current system time.

Examples

In the following example, we ZIP up the resource/fonts subdirectory within the IDL installation, and then UNZIP the file into our current working directory:

dir = FILEPATH('', SUBDIR=['resource','fonts'])

FILE_ZIP, dir, 'idlresources.zip'

FILE_UNZIP, 'idlresources.zip', /VERBOSE

IDL prints:

% fonts\

% fonts\hersh1.chr, 44667 bytes

...

% fonts\tt\ttfont.map, 305 bytes

% Total 61 files, 963401 bytes

% Time elapsed: 0.070999861 seconds.

 

Here, we get the list of all files in a ZIP, and extract only the first five files into our current working directory:

dir = FILEPATH('', SUBDIR=['resource','fonts'])

FILE_ZIP, dir, 'idlresources.zip'

FILE_UNZIP, 'idlresources.zip', /LIST, FILES=files

FILE_UNZIP, 'idlresources.zip', EXTRACT_FILES=files[0:4], /VERBOSE

IDL prints:

% fonts\

  Extracted file fonts\

% fonts\hersh1.chr, 44667 bytes

  Extracted file fonts\hersh1.chr

% fonts\ps\

  Extracted file fonts\ps\

% fonts\ps\Arimo-Bold.pfa, 70394 bytes

  Extracted file fonts\ps\Arimo-Bold.pfa

% fonts\ps\Arimo-BoldItalic.pfa, 69769 bytes

  Extracted file fonts\ps\Arimo-BoldItalic.pfa

% fonts\ps\Arimo-Italic.pfa, 61646 bytes

  Skipped file fonts\ps\Arimo-Italic.pfa

...

% fonts\tt\ttfont.map, 334 bytes

  Skipped file fonts\tt\ttfont.map

% Total 5 files, 5906340 bytes

% Time elapsed: 0.059000015 seconds.

Syntax

FILE_UNZIP, File [, DirectoryOut] [, FILES=variable] [, /LIST] [, /VERBOSE] [, /EXTRACT_FILES]

Arguments

File

Set this argument to a scalar string giving the file to unzip.

DirectoryOut

Set this optional argument to a scalar string giving the output directory. This directory will be created if it does not currently exist. If DirectoryOut is not provided then FILE_UNZIP will unzip into File's current directory.

Keywords

EXTRACT_FILES

Set this keyword to a string or array of strings with the names of the files to be extracted from the zip. Unknown filenames will be ignored.

FILES

Set this keyword to a named variable. On return, this variable will contain a string array of all of the files that were unzipped.

LIST

Set this keyword to perform all of the FILE_UNZIP actions without actually unzipping the file. The list of files can be retrieved using the FILES keyword, while the VERBOSE keyword will output the list of directories and files within the ZIP file.

VERBOSE

Set this keyword to output additional information while the routine is executing.

Version History

8.2.3

Introduced

8.7

Added EXTRACT_FILES keyword

See Also

FILE_GZIP, FILE_GUNZIP, FILE_TAR, FILE_UNTAR, FILE_ZIP, ZLIB_COMPRESS, ZLIB_UNCOMPRESS