Constructs the file system. You must provide the directory listing as a JSON object
produced by the make_xhrfs_index
script.
If you install BrowserFS globally with npm i -g browserfs
, you can generate a listing by
running make_xhrfs_index
in your terminal in the directory you would like to index:
make_xhrfs_index > index.json
Listings objects look like the following:
{
"home": {
"jvilk": {
"someFile.txt": null,
"someDir": {
// Empty directory
}
}
}
}
This example has the folder /home/jvilk
with subfile someFile.txt
and subfolder someDir
.
Alternatively, you can construct an XmlHttpRequest object by calling the static FromURL
function:
BrowserFS.FileSystem.XmlHttpRequest.FromURL('http://example.com/files/index.json');
DEPRECATED: You may pass a URL to the file index to the constructor, which will fetch the file index synchronously and may freeze up the web page. This behavior will be removed in the next major version of BrowserFS.
index object or the path to the JSON file index generated by
make_xhrfs_index
.
URL that is prepended to any file locations in the file index. e.g. if prefixUrl = 'data/
, and the user wants to open the file /foo.txt
,
the file system will fetch file data/foo.txt
. The browser will access the file relative to the currrent webpage
URL.
Create the file at path p with the given mode. Then, open it with the given flag.
Opens the file at path p with the given flag. The file must exist.
The path to open.
The flag to use when opening the file.
Special XHR function: Preload the given file into the index.
We have the entire file as a buffer; optimize readFile.
Specially-optimized readfile.
Constructs an XmlHttpRequest object using the directory listing at the given URL. Uses the base URL as the URL prefix for fetched files.
Called when the file system has been instantiated, or if an error occurs.
Generated using TypeDoc
A simple filesystem backed by XMLHttpRequests.