Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more Deno filesystem functionality? #19

Open
xyzshantaram opened this issue Dec 30, 2021 · 2 comments
Open

Support more Deno filesystem functionality? #19

xyzshantaram opened this issue Dec 30, 2021 · 2 comments

Comments

@xyzshantaram
Copy link

It would be really useful if Leaf supported functions like stat, readDir, walkDir, etc so that library functions expecting a whole filesystem (for example, Opine's send, which uses stat and is used internally by the serveStatic function to serve static files) will work.

I understand if this is out of the scope of Leaf, but since we are meant to use Leaf with the fs text file r/w functions it would be nice to have this too, esp since Leaf is a fake filesystem.

A really cool use-case for Leaf, IMO, is single-file web servers in the vein of redbean but which allow us to use TypeScript and Deno, and this feature would enable that.

@clemens-tolboom
Copy link
Contributor

I'm still learning Leaf but write is not an option as leaf is a readonly key/value store.

globalThis["MANDARINE_FILE_SYSTEM"] = {"web/index.html":[byte,...],...}

Regarding readDir/walkDir you can find the tree yourself so maybe write a PR?

function dumpLeaf() {
    console.debug("dumpLeaf", globalThis);
    Object.keys(globalThis["MANDARINE_FILE_SYSTEM"]).forEach(v => console.log(v));
}

gives

web/favicon.ico
web/index.html
...

@xyzshantaram
Copy link
Author

Ah, ofc, writing won't work, I meant more of the reading functions, yes. I'll try and write a PR later today but I can't promise anything (I'm kinda busy since my college semester starts tomorrow).

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants