e-CryptIt Engine - Compression Xojo Plugin |
|
EinhugurZstandard.CompressTask Method
Sets up a compression task for native Thread execution
This function can raise the following exceptions:
When running the task returned by this function then the following exception can be thrown:

CompressTask(
compressionLevel
as Integer,
overwrite
as Boolean)
as EinhugurRuntime.Task
Parameters
- compressionLevel
- Compression level. (optional parameter) This can be anything from -22 to 22. Where negative values are special values to focus speed over size. Default value is 3. 20 is max safe value. 22 is absolute maximum value.
- overwrite
- If set to true then destination will be replaced if it exists. If set to false and destination exists then exception will be thrown.
Returns
- EinhugurRuntime.Task
- The compression task.
Remarks
Both source and destination must be file based. As native thread cannot talk to Xojo objects which would be needed to talk to the Stream interfaces.
If source or destination is not File in a FolderItem then exception will be thrown.
Warning: If your TypeLib plugin is not version 11.2 or later then you will get crash if setting up native task like this.
var fileExtension as new FileType
fileExtension.Name = "Any"
fileExtension.Extensions = "*"
var source as FolderItem = FolderItem.ShowOpenFileDialog(fileExtension)
if source <> nil then
var dest as FolderItem = source.Parent.Child(source.Name + "." + EinhugurZstandard.FileExtension)
if dest <> nil then
try
var cstd as new EinhugurZstandard(source, dest)
cstd.SetProgressHandler(AddressOf OnProgress)
var task as EinhugurRuntime.Task = cstd.CompressTask(EinhugurZstandard.CompressionLevelDefault)
task.WaitFor()
MessageBox "Done"
catch e as InvalidArgumentException
MessageBox("IOException: " + e.Message)
catch e as InvalidArgumentException
MessageBox("InvalidArgumentException: " + e.Message)
end try
end if
end if
See Also
EinhugurZstandard Class