DataDecompress Event

Fires to decompress a block of data using a custom compression algorithm.

Syntax

// CBDriveDataDecompressEventArgs carries the CBDrive DataDecompress event's parameters.
type CBDriveDataDecompressEventArgs struct {...}

func (args *CBDriveDataDecompressEventArgs) InData() []byte
func (args *CBDriveDataDecompressEventArgs) InSize() int32
func (args *CBDriveDataDecompressEventArgs) OutData() []byte
func (args *CBDriveDataDecompressEventArgs) SetOutData(value []byte)
func (args *CBDriveDataDecompressEventArgs) OutSize() int32
func (args *CBDriveDataDecompressEventArgs) SetOutSize(value int32)
func (args *CBDriveDataDecompressEventArgs) ResultCode() int32
func (args *CBDriveDataDecompressEventArgs) SetResultCode(value int32)

// CBDriveDataDecompressEvent defines the signature of the CBDrive DataDecompress event's handler function.
type CBDriveDataDecompressEvent func(sender *CBDrive, args *CBDriveDataDecompressEventArgs)

func (obj *CBDrive) GetOnDataDecompressHandler() CBDriveDataDecompressEvent
func (obj *CBDrive) SetOnDataDecompressHandler(handlerFunc CBDriveDataDecompressEvent)

Remarks

This event fires when the component needs to decompress a block of data using an application-defined compression algorithm. Please refer to the Compression topic for more information.

This event only needs to be handled by applications that use the CBFSSTORAGE_CM_CUSTOM compression mode. To handle this event properly, applications must decompress all InSize bytes of data in the InData buffer, write the decompressed data to the OutData buffer, and set OutSize to reflect the total number of bytes written to OutData.

Note that OutSize is initially set to the capacity of the OutData buffer, which (under normal circumstances) should be large enough to accommodate all of the decompressed data. Only if the vault is corrupted should the OutData buffer ever be too small to hold the decompressed data; so if this occurs, do not write any data to OutData. Instead, set ResultCode to CBFSSTORAGE_ERR_VAULT_CORRUPTED.

Please refer to the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a non-zero value to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.

Note: An application should not attempt to call component's methods from handlers of this event. Doing this is guaranteed to cause a deadlock.

Note: when a storage is opened concurrently in read-only mode by several applications using CBDrive or CBMemDrive component, the event will fire only in the first application. To prevent such a situation, always open a vault in read-write mode.

Copyright (c) 2021 Callback Technologies, Inc. - All rights reserved.
CBFS Storage 2020 Go Edition - Version 20.0 [Build 8031]