Sample code for 30+ languages & platforms
Tcl

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set bz2 [new_CkBz2]

# Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
set success [CkBz2_CompressFile $bz2 "qa_data/hamlet.xml" "qa_output/hamlet.bz2"]
if {$success != 1} then {
    puts [CkBz2_lastErrorText $bz2]
    delete_CkBz2 $bz2
    exit
}

puts "Success."

delete_CkBz2 $bz2