---
layout: doc
title: general / compress_file
---
# compress_file

### NAME

    compress_file() - gzip a file on disk

### SYNOPSIS

    int compress_file( string input_file, void | string output_file );

### DESCRIPTION

    Compresses input_file with gzip compression and writes the result to
    output_file.  If output_file is omitted, the driver writes to input_file
    with ".gz" appended.

    On success, the original input_file is deleted and 1 is returned.  On
    failure, 0 is returned.  Failure cases include invalid arguments, invalid
    read or write permissions, an input file that cannot be opened, an output
    file that cannot be opened, or omitting output_file when input_file
    already ends in ".gz".

    The paths are checked through the driver's normal valid_read() and
    valid_write() mechanisms.

### SEE ALSO

    uncompress_file(3), compress(3), uncompress(3), valid_read(4),
    valid_write(4)
