-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
42 changes: 42 additions & 0 deletions
42
sites/cheerpx/src/content/docs/12-reference/CheerpX.WebDevice/create.md
This file contains 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,42 @@ | ||
--- | ||
title: create | ||
description: Create a CheerpX WebDevice instance, representing a read-only HTTP-based filesystem for CheerpX. | ||
--- | ||
|
||
```ts | ||
namespace CheerpX { | ||
class WebDevice { | ||
static async create(path: string): Promise<WebDevice>; | ||
} | ||
} | ||
``` | ||
|
||
## Parameters | ||
|
||
- **path (`string`)** - The path to the local directory you want to mount. | ||
|
||
## Returns | ||
|
||
`CheerpX.WebDevice.create` returns a [Promise] that gives you a `WebDevice` instance. You can use this instance to mount the specified directory in the CheerpX filesystem. | ||
|
||
## Example | ||
|
||
Create a `webDevice` instance for the `/webdevice` directory. | ||
|
||
```js | ||
// Add a device to expose a directory on the HTTP server in the VM | ||
const webDevice = await CheerpX.WebDevice.create("/webdevice"); | ||
|
||
// Initialize the CheerpX environment | ||
const mountPoints = [ | ||
// Mount the WebDevice to a known location | ||
{ type: "dir", path: "/webdevice", dev: webDevice }, | ||
]; | ||
const cx = await CheerpX.Linux.create({ | ||
mounts: mountPoints, | ||
}); | ||
``` | ||
|
||
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 |