Skip to content

Commit 87ced78

Browse files
committed
docs
1 parent 4720bce commit 87ced78

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

system/include/emscripten/wasmfs.h

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,32 @@ typedef backend_t (*backend_constructor_t)(void*);
4848

4949
backend_t wasmfs_create_memory_backend(void);
5050

51+
// Fetch backend
52+
//
53+
// Creates a new fetchfs backend. FetchFS will backstop filesystem
54+
// reads to HTTP fetch requests, which will download just specific
55+
// ranges of the requested files. FetchFS works best when your web
56+
// server supports HTTP range requests, and it's important that those
57+
// files are not stored encrypted or compressed at rest. FetchFS by
58+
// default will dispatch HTTP requests to URLs beginning with base_url
59+
// and ending with whatever the file's path is relative to where the
60+
// fetchfs directory is mounted.
61+
//
62+
// You can also provide a `manifest`, which is a mapping from file
63+
// paths (again, relative to where the fetchfs is mounted) to URLs
64+
// (relative to base_url). This is useful if your C program expects
65+
// files at certain locations, while your web server may have those
66+
// files at arbitrary different locations. The manifest can be built
67+
// using wasmfs_fetch_create_manifest and
68+
// wasmfs_fetch_add_to_manifest. When the fetchfs is mounted,
69+
// directories and files corresponding to the manifest entries will be
70+
// automatically created.
71+
//
72+
// For example, a manifest like `{'/test.txt':'resources/file.txt'}`
73+
// mounted at `/dat` (using either wasmfs_mount or
74+
// wasmfs_create_directory) will let you write `open("/dat/test.txt",
75+
// O_RDONLY)`.
76+
//
5177
// Note: this cannot be called on the browser main thread because it might
5278
// deadlock while waiting for its dedicated worker thread to be spawned.
5379
//
@@ -57,15 +83,17 @@ backend_t wasmfs_create_memory_backend(void);
5783
//
5884
// TODO: Add an async version of this function that will work on the main
5985
// thread.
86+
//
6087
backend_t wasmfs_create_fetch_backend(const char* base_url __attribute__((nonnull)),
6188
uint32_t chunkSize,
6289
void *manifest);
6390

64-
// Create a FetchFS manifest record that can be populated and passed into
91+
// Create a FetchFS manifest record that can be populated with
92+
// wasmfs_fetch_add_to_manifest and passed into
6593
// wasmfs_fetch_create_backend.
6694
void *wasmfs_fetch_create_manifest();
6795

68-
// Add a path to URL mapping to the given manifest.
96+
// Add a path-to-URL mapping to the given manifest.
6997
void wasmfs_fetch_add_to_manifest(void *manifest __attribute__((nonnull)),
7098
const char *path __attribute__((nonnull)),
7199
const char *url __attribute__((nonnull)));

0 commit comments

Comments
 (0)