Closed andres-asm closed 8 years ago
Oof, thanks for the report! You've found two bugs in the code:
function
.AsyncMirror
, not AsyncMirrorFS
.I'll have to update the docs when I next get a chance! Here's the corrected version:
/**
* Run this prior to starting your Emscripten module.
* @param dropboxClient An authenticated DropboxJS client.
*/
function asyncSetup(dropboxClient, cb) {
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
// Wrap in AsyncMirrorFS.
var asyncMirror = new BrowserFS.FileSystem.AsyncMirror(
new BrowserFS.FileSystem.InMemory(), dbfs);
// Downloads the entire contents of the Dropbox backend into memory.
// You'll probably want to use an app folder, and check that you
// aren't pulling in a huge amount of data here.
asyncMirror.initialize(function(err) {
// Initialize it as the root file system.
BrowserFS.initialize(asyncMirror);
// BFS is ready for Emscripten!
cb();
});
}
function setupBFS() {
// Grab the BrowserFS Emscripten FS plugin.
var BFS = new BrowserFS.EmscriptenFS();
// Create the folder that we'll turn into a mount point.
FS.createFolder(FS.root, 'data', true, true);
// Mount BFS's root folder into the '/data' folder.
FS.mount(BFS, {root: '/'}, '/data');
}
Thanks!
I got further now, but I'm still getting an error
console.log("WEBPLAYER: Initializing DropBoxFS");
var BFS = new BrowserFS.EmscriptenFS();
FS.createFolder(FS.root, 'retroarch', true, true);
FS.mount(BFS, {root: '/'}, '/retroarch');
console.log('WEBPLAYER: DropBox initialized');
TypeError: this.root is null on this call FS.mount(BFS, {root: '/'}, '/retroarch');
NVM, finally understood it and it's working thanks a lot!
Thanks a lot for your help This is my code, it might be bad or not idk, it's my first ever interaction with js but it works and I wasn't able to find any other samples.
https://github.com/libretro/RetroArch/blob/master/emscripten/webplayer.html https://bot.libretro.com/.radius/webplayer.html
:) The code looks decent to me! Glad to hear it all worked out.
I tried to copy your AsyncMirror examplecode
but I have two issues (so far)
SyntaxError: expected expression, got ')' here asyncMirror.initialize((err?) => {
And AsyncMirrorFS is not a constructor.
I'm a js newbie, I'm trying to integrate dropbox to retroarch emscripten, I'm not sure if there is a sintax error there or I'm just failing to understand js