VaultOpen Event

Fires to open a new or existing callback mode vault.

Syntax

ANSI (Cross Platform)
virtual int FireVaultOpen(CBDriveVaultOpenEventParams *e);
typedef struct {
const char *Vault;
int64 *pVaultHandle;
int OpenMode;
int ReadOnly;
int ResultCode; int reserved; } CBDriveVaultOpenEventParams; Unicode (Windows) virtual INT FireVaultOpen(CBDriveVaultOpenEventParams *e);
typedef struct {
LPCWSTR Vault;
LONG64 *pVaultHandle;
INT OpenMode;
BOOL ReadOnly;
INT ResultCode; INT reserved; } CBDriveVaultOpenEventParams;
- (void)onVaultOpen:(NSString*)vault :(long long*)vaultHandle :(int)openMode :(int*)readOnly :(int*)resultCode;
#define EID_CBDRIVE_VAULTOPEN 16

virtual INT CBFSSTORAGE_CALL FireVaultOpen(LPWSTR &lpszVault, LONG64 &lVaultHandle, INT &iOpenMode, BOOL &bReadOnly, INT &iResultCode);

Remarks

This event fires when the class 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 class 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 class'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 class, 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 C++ Edition - Version 20.0 [Build 8031]