Fires to open a new or existing callback mode vault.
- (void)onVaultOpen:(NSString*)vault :(long long*)vaultHandle :(int)openMode :(int*)readOnly :(int*)resultCode;
func onVaultOpen(_ vault: String, _ vaultHandle: inout Int64, _ openMode: Int32, _ readOnly: inout Int32, _ resultCode: inout Int32)
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_NEW||0||Creates a new vault if possible, failing if one already exists.|
|CBFSSTORAGE_OM_CREATE_ALWAYS||1||Creates a new vault, overwriting an existing one if necessary.|
|CBFSSTORAGE_OM_OPEN_EXISTING||2||Opens a vault if it exists; fails otherwise.|
|CBFSSTORAGE_OM_OPEN_ALWAYS||3||Opens 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.