CreateStorage Method

Creates the virtual drive.

Syntax

ANSI (Cross Platform)
int CreateStorage();

Unicode (Windows)
INT CreateStorage();
- (void)createStorage;
#define MID_CBDISK_CREATESTORAGE 4

CBFSSTORAGE_EXTERNAL int CBFSSTORAGE_CALL CBFSStorage_CBDisk_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

This method creates the virtual drive (without mounting points) based on the following properties, which cannot be changed once the virtual storage has been created:

(Note that there are many other properties which, while not directly used by this method, nonetheless cannot be changed once a virtual drive is created. Such restrictions are noted where applicable.)

After the virtual drive is created, use the MountMedia method to "insert storage media" into the virtual drive, and use the AddMountingPoint method to create one or more mounting points for it.

The Initialize method must have been called by some class instance in the application prior to calling this method.

Note: This method cannot be called within events.

Virtual Drives and Mounting Points

CBDrive and CBMemDrive components: When applications call the OpenVault (CBDrive) or CreateVault method, the specified vault is opened and used to create and mount a virtual drive. This virtual drive is created without a drive letter.

To add a drive letter for the virtual drive, applications have to call the AddMountingPoint method. Once a drive letter is assigned, the virtual drive will be visible to the system and other applications, allowing them to start accessing its files and directories.

CBDisk component:

When applications call the CreateStorage method, a virtual drive is created. Virtual drives are created without any "media" in them (like a CD drive without a CD inserted), and without any mounting points (drive letters, UNC paths, etc.).

After creating a virtual drive, applications should call MountMedia to "insert" virtual storage media into the virtual drive. This call will cause the class's events to start firing; applications must handle these events correctly, or the MountMedia call will fail.

Once media has been mounted in the virtual drive, applications should use the AddMountingPoint method to add one or more mounting points for the virtual drive. These mounting points make the virtual drive, visible to the system and other applications, allowing them to start accessing the contents of the CBDisk-based virtual filesystem.

Note that applications can technically call AddMountingPoint before MountMedia (except for plug-and-play virtual drives with non-removable media; see StorageType), but any attempts to access a virtual drive with no media mounted will result in a "no media" error.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

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