Closed mjohngladson closed 1 year ago
Please have a look at the Readme.md it explains how to initialize a filesystem.
readme does not explain BrowserFS.initialize
some examples
BrowserFS.initialize(new BrowserFS.FileSystem.InMemory());
callbacks http://jvilk.com/browserfs/1.4.1/#advanced-usage
BrowserFS.FileSystem.LocalStorage.Create(function(e, lsfs) {
BrowserFS.FileSystem.InMemory.Create(function(e, inMemory) {
BrowserFS.FileSystem.IndexedDB.Create({}, function(e, idbfs) {
BrowserFS.FileSystem.MountableFileSystem.Create({
'/tmp': inMemory,
'/home': idbfs,
'/mnt/usb0': lsfs
}, function(e, mfs) {
BrowserFS.initialize(mfs);
// BFS is now ready to use!
});
});
});
});
async await, example from https://github.com/milahu/browsix
import { onMount, createSignal, Show } from "solid-js";
import pify from "pify";
import * as BrowserFS from "browserfs";
import {BootWith} from "../src/kernel/kernel"
import {Terminal} from "./elements/browsix-terminal/browsix-terminal"
export default function App() {
const [getKernel, setKernel] = createSignal();
onMount(async () => {
const rootFs = await pify(BrowserFS.FileSystem.MountableFileSystem.Create)({
'/tmp': await pify(BrowserFS.FileSystem.InMemory.Create)({}),
'/home': await pify(BrowserFS.FileSystem.IndexedDB.Create)({}),
})
BrowserFS.initialize(rootFs);
BootWith(rootFs, setKernel);
});
return (
<Show when={getKernel()} fallback={<div>Loading kernel ...</div>}>
<Terminal kernel={getKernel()}/>
</Show>
)
}
I get the below error in my react app while trying to write to text file
"Initialize BrowserFS with a file system using BrowserFS.initialize(filesystem)"
after analysing found the root was null.
Can someone please help how to set the root/ how to initialize?