(Tcl) Example for the Zip AppendNew Function
Demonstrates the Zip AppendNew function.
load ./chilkat.dll
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set zip [new_CkZip]
set zipPath "c:/temp/test.zip"
# Initialize the zip object, which also sets the FileName property to the path of the zip to be created.
CkZip_NewZip $zip $zipPath
# Append a new and empty file to the zip object.
# This does not write the zip file. It simply adds an entry
# that will get processed when the zip is written.
# entry1 is a CkZipEntry
set entry1 [CkZip_AppendNew $zip "empty.txt"]
delete_CkZipEntry $entry1
# Append another entry..
# entry2 is a CkZipEntry
set entry2 [CkZip_AppendNew $zip "abc/helloWorld.txt"]
# Add some data to this entry..
CkZipEntry_AppendString $entry2 "Hello World" "utf-8"
delete_CkZipEntry $entry2
# Write the zip, which contains 2 files: empty.txt and helloWorld.txt
CkZip_put_FileName $zip $zipPath
set success [CkZip_WriteZipAndClose $zip]
if {$success == 0} then {
puts [CkZip_lastErrorText $zip]
delete_CkZip $zip
exit
}
puts "Success."
delete_CkZip $zip
|