Navigation

Search

read_tgz_data

Description

Extracts a file or files from the .tar.gz contained in data (called from read_tgz_file).

Syntax

array read_tgz_data (string $data, string $destination[, bool $single_file[, bool $overwrite]])



Parameter $data

Expected type: String
Description: The raw data from the file (from read_tgz_file)



Parameter $destination

Expected type: String
Description: Null to return a listing of files in the archive, the actual destination for the contents of the archive, or (if single_file is true), the name of the file to get



Parameter $single_file

Expected type: Boolean
Description: If true, returns either the contents of the file specified by destination, or false if the specified file couldn't be found (default value is false).



Parameter $overwrite

Expected type: Boolean
Description: If true, overwrites existing files with newer modification times (default is false)



Return value

Expected type: Array
Description: An array of files extracted from the archive, or false if there was a problem


Notes

  • Detects if the file is really a .zip file, and if so returns the result of read_zip_data
  • If destination is null, returns a list of files in the archive.
  • If single_file is true, returns the contents of the file specified by destination, if it exists, or false.
  • If single_file is true, destination can start with * and / to signify that the file may come from any directory.
  • Destination should not begin with a / if single_file is true.
  • Overwrites existing files with newer modification times if and only if overwrite is true.
  • Creates the destination directory if it doesn't exist, and is specified.
  • Requires zlib support be built into PHP.
  • Returns an array of the files extracted.
View all versions of this function