-
Notifications
You must be signed in to change notification settings - Fork 19
CX overlayDevice reference added #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9acbd9a
Add OverlayDevice reference
AtibQur 9b81d1f
Added text
AtibQur 4160b80
Added links
AtibQur dc471e8
prettier
AtibQur 18b954c
Merge branch 'main' into CheerpX_overlaydevice
AtibQur a1ed28e
Added links
AtibQur bedb630
Added related sources
AtibQur 2c09a7b
Added links
AtibQur 7e10dd2
Changed text
AtibQur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
sites/cheerpx/src/content/docs/12-reference/CheerpX.OverlayDevice/create.md
AtibQur marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| --- | ||
| title: create | ||
| description: Create a writable persistent overlay device on top of another block device. | ||
| --- | ||
|
|
||
| ```ts | ||
| namespace CheerpX { | ||
| class OverlayDevice { | ||
| static async create( | ||
| baseDevice: Device, | ||
| overlayDevice: Device | ||
| ): Promise<OverlayDevice>; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Parameters | ||
|
|
||
| - **baseDevice (`Device`)** - The underlying device (e.g., `HttpBytesDevice`, `IDBDevice`) that serves as the base layer for the filesystem. | ||
|
|
||
| - **overlayDevice (`Device`)** - The writable layer that will overlay the base device, enabling persistent changes. | ||
|
|
||
| ## Returns | ||
|
|
||
| `CheerpX.OverlayDevice.create` returns a [Promise] that resolves to an instance of the `OverlayDevice`. The `OverlayDevice` allows you to overlay a writable layer on top of the base device, enabling persistent changes while still accessing the base data. | ||
|
|
||
| ## Example | ||
|
|
||
| Create an `OverlayDevice` instance to combine a `HttpBytesDevice` for streaming data from an HTTP source and an `IDBDevice` for caching and persistent local storage. | ||
|
|
||
| ```ts {8, 12} | ||
| // Create a read-only HttpBytesDevice for streaming disk blocks via HTTP | ||
| const httpDevice = await CheerpX.HttpBytesDevice.create("/cheerpXImage.ext2"); | ||
|
|
||
| // Create an IDBDevice for local persistent storage | ||
| const idbDevice = await CheerpX.IDBDevice.create("block_idbDevice"); | ||
|
|
||
| // Create an OverlayDevice to combine the two devices | ||
| const overlayDevice = await CheerpX.OverlayDevice.create(httpDevice, idbDevice); | ||
|
|
||
| // Mount the overlay device in the CheerpX environment as an ext2 filesystem | ||
| const cx = await CheerpX.Linux.create({ | ||
| mounts: [{ type: "ext2", path: "/", dev: overlayDevice }], | ||
| }); | ||
| ``` | ||
|
|
||
| In this example, the `OverlayDevice` provides a writable layer on top of the `HttpBytesDevice` (which serves as a read-only block device for streaming), allowing changes to be stored locally via the `IDBDevice`. | ||
|
|
||
| ## Related sources | ||
|
|
||
| - [CheerpX.HttpBytesDevice](/docs/reference/httpBytesDevice) | ||
| - [CheerpX.IDBDevice](/docs/reference/CheerpX.IDBDevice) | ||
| - [CheerpX.Linux](/docs/reference/CheerpX.Linux) | ||
|
|
||
| For more information, please check out the [Files and File system guide](/docs/guides/File-System-support). This guide provides more details on how to work with files and directories in CheerpX. | ||
|
|
||
| [Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.