Oihana PHP

bzip2File.php

Table of Contents

Functions

bzip2File()  : string
Compresses a single file with bzip2, streaming it in chunks.

Functions

bzip2File()

Compresses a single file with bzip2, streaming it in chunks.

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

Standalone bzip2 compression outside of tar archives, using the bz2 extension — no subprocess, and the file is never fully loaded into memory.

Unlike gzipFile(), no compression level is exposed: bzopen() does not accept one in streaming mode.

Parameters
$source : string

Path to the file to compress.

$destination : string|null = null

Output path. Defaults to $source + .bz2.

$overwrite : bool = true

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

Tags
throws
FileException

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

author

Marc Alcaraz (ekameleon)

since
1.2.0
example
use function oihana\files\bzip2File;

bzip2File( '/data/dump.sql' ) ; // -> /data/dump.sql.bz2
Return values
string

The destination path.

On this page

Search results