create
Create a CheerpX IDBDevice instance to store data in the browserโs IndexedDB with read and write access.
namespace CheerpX { class IDBDevice { static async create(dbName: string): Promise<IDBDevice>; }}
Parameters
- dbName (
string
) - The name ofIndexedDB
where the filesystem will be stored.
Returns
CheerpX.IDBDevice.create
returns a Promise that gives you an
IDBDevice
instance. You can use this instance to create a virtual filesystem stored in IndexedDB
within your CheerpX environment.
Example
Create an IDBDevice
instance for persistent storage.
// Create a read-only block device for a disk image stored on the HTTP serverconst blockDevice = await CheerpX.HttpBytesDevice.create("/cheerpXImage.ext2");// Make the block device read-write using a persistent IndexedDB overlayconst idbDevice = await CheerpX.IDBDevice.create("block_idbDevice");const overlayDevice = await CheerpX.OverlayDevice.create( blockDevice, idbDevice);// Initialize the CheerpX environmentconst mountPoints = [ // Use the disk image as the filesystem root { type: "ext2", path: "/", dev: overlayDevice },];const cx = await CheerpX.Linux.create({ mounts: mountPoints,});
If youโd like to learn more about related topics, check out these guides:
- Files and filesystems โ Managing files and storage in CheerpX.
- Input and output โ Handling data flow in your environment.