VaultOpen Event

Fires to open a new or existing callback mode vault.


// CBVaultVaultOpenEventArgs carries the CBVault VaultOpen event's parameters.
type CBVaultVaultOpenEventArgs struct {...}

func (args *CBVaultVaultOpenEventArgs) Vault() string
func (args *CBVaultVaultOpenEventArgs) VaultHandle() int64
func (args *CBVaultVaultOpenEventArgs) SetVaultHandle(value int64)
func (args *CBVaultVaultOpenEventArgs) OpenMode() int32
func (args *CBVaultVaultOpenEventArgs) ReadOnly() bool
func (args *CBVaultVaultOpenEventArgs) SetReadOnly(value bool)
func (args *CBVaultVaultOpenEventArgs) ResultCode() int32
func (args *CBVaultVaultOpenEventArgs) SetResultCode(value int32)

// CBVaultVaultOpenEvent defines the signature of the CBVault VaultOpen event's handler function.
type CBVaultVaultOpenEvent func(sender *CBVault, args *CBVaultVaultOpenEventArgs)

func (obj *CBVault) GetOnVaultOpenHandler() CBVaultVaultOpenEvent
func (obj *CBVault) SetOnVaultOpenHandler(handlerFunc CBVaultVaultOpenEvent)


This event fires when the component wants to open the callback mode vault identified by Vault.

This event only needs to be handled if the CallbackMode property is enabled; please refer to the Callback Mode topic for more information. To handle this event properly, applications must open the vault identified by Vault, creating it if necessary based on the specified OpenMode, and return a handle to it in VaultHandle.

If the ReadOnly parameter is initially true, the application must open the vault in read-only mode. If ReadOnly is initially false, the application may choose whether to open the vault in read-only or read-write mode, and should update the ReadOnly parameter accordingly, if necessary.

If, for any reason, the vault cannot be opened in a manner consistent with the specified OpenMode, the application must set VaultHandle to -1 and return an appropriate error code via ResultCode.

The Vault parameter contains an application-defined vault identifier (name, file path, etc.). The value of this parameter will always match the current value of the VaultFile property.

The VaultHandle parameter is used to return some application-defined handle that uniquely identifies the opened vault. The component uses the returned handle to populate the VaultHandle parameters of the other Vault* events fired for the vault later.

The OpenMode parameter specifies what behavior to use when opening the vault. Valid values are:

CBFSSTORAGE_OM_CREATE_NEW0Creates a new vault if possible, failing if one already exists.

CBFSSTORAGE_OM_CREATE_ALWAYS1Creates a new vault, overwriting an existing one if necessary.

CBFSSTORAGE_OM_OPEN_EXISTING2Opens a vault if it exists; fails otherwise.

CBFSSTORAGE_OM_OPEN_ALWAYS3Opens a vault if it exists; creates a new one otherwise.

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 Vault 2020 Go Edition - Version 20.0 [Build 7982]