Oihana PHP

gunzipFile.php

Table of Contents

Functions

gunzipFile()  : string
Decompresses a single gzip file, streaming it in chunks.

Functions

gunzipFile()

Decompresses a single gzip file, streaming it in chunks.

gunzipFile(string $source[, string|null $destination = null ][, bool $overwrite = true ]) : string

Counterpart of gzipFile(), using the zlib extension — no subprocess, and the file is never fully loaded into memory.

Parameters
$source : string

Path to the gzip file to decompress.

$destination : string|null = null

Output path. Defaults to $source without its .gz suffix, or $source + .out when the source has no .gz suffix.

$overwrite : bool = true

Whether to overwrite an existing destination (default: true).

Tags
throws
FileException

If the source is invalid, zlib is unavailable, the destination exists and $overwrite is false, or decompression fails.

author

Marc Alcaraz (ekameleon)

since
1.2.0
example
use function oihana\files\gunzipFile;

gunzipFile( '/var/log/app.log.gz' ) ; // -> /var/log/app.log
Return values
string

The destination path.

On this page

Search results