CBFS Storage 2020 .NET Edition

Questions / Feedback?

VaultOpen Event

Fires to open a new or existing callback mode vault.

Syntax

public event OnVaultOpenHandler OnVaultOpen;

public delegate void OnVaultOpenHandler(object sender, CbvaultVaultOpenEventArgs e);

public class CbvaultVaultOpenEventArgs : EventArgs {
  public string Vault { get; }
  public long VaultHandle { get; set; }
  public int OpenMode { get; }
  public bool ReadOnly { get; set; }
  public int ResultCode { get; set; }
}
Public Event OnVaultOpen As OnVaultOpenHandler

Public Delegate Sub OnVaultOpenHandler(sender As Object, e As CbvaultVaultOpenEventArgs)

Public Class CbvaultVaultOpenEventArgs Inherits EventArgs
  Public ReadOnly Property Vault As String
  Public Property VaultHandle As Long
  Public ReadOnly Property OpenMode As Integer
  Public Property ReadOnly As Boolean
  Public Property ResultCode As Integer
End Class

Remarks

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 Storage 2020 .NET Edition - Version 20.0 [Build 8031]