Compress()
Compress given source to different formats.
Compress( format=string, source=string, target=string, includeBaseFolder=boolean, mode=string );
Returns: Boolean
| Argument | Description | Default |
|---|---|---|
|
format
string,
required
|
edit
Compression Format
|
|
|
source
string,
required
|
edit
source file or directory to compress Note: For gzip & bzip format must use the file path as the source |
|
|
target
string,
required
|
edit
name of the target compressed file |
|
|
includeBaseFolder
boolean,
optional
|
edit
take the folder or only content of folder |
true |
|
mode
string,
optional
|
edit
mode of the values |
777 |
Examples
edittest_file = fileOpen("test.txt", "append");
fileWriteLine(test_file, "The Lucee project is led by the Lucee Association Switzerland a non-profit swiss association. A growing project which is committed to the success of its community by delivering quality software and a nurturing and supportive environment for developers to get involved.");
fileWriteLine(test_file, "");
fileWriteLine(test_file, "The members of the Lucee Association Switzerland are responsible for steering the direction of the association. We are proud to have members from around the world that guide the association with their in-depth skills across the board. Being a member however is not an one-way street and there are many ways you can benefit from being a member.");
fileWriteLine(test_file, "");
fileClose(test_file);
// compress the original file
Compress("gzip","test.txt","compressed_test.txt");
dump(GetFileInfo("test.txt").size);
dump(GetFileInfo("compressed_test.txt").size);
// remove the files to keep clutter down
filedelete("test.txt");
filedelete("compressed_test.txt");
See also
- Zip files
- Extract()
- <cfzip>
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)