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

lookupPath for non-existent path #507

Open
Dual-Ice opened this issue Jan 21, 2025 · 2 comments
Open

lookupPath for non-existent path #507

Dual-Ice opened this issue Jan 21, 2025 · 2 comments
Labels
feature New feature or request

Comments

@Dual-Ice
Copy link

Hi, please tell me why when I use this.webr.FS.lookupPath(path) where path is some non-existent path - I get an error instead of, say, null or undefined.
Because of this, I have to write hacks with try catch to check if something exists at the passed path.

@georgestagg
Copy link
Member

The webR.FS interface is a thin wrapper around Emscripten's File System API. Quoting from the Emscripten docs,

Emscripten predominantly compiles code that uses synchronous file I/O, so the majority of the FS member functions offer a synchronous interface (with errors being reported by raising exceptions of type FS.ErrnoError).

That is, for these functions throwing exceptions to be caught with try/catch is by design.

Saying that, there now exists a function FS.analyzePath in Emscripten which

[...]provides more information about given path and its parent. If any error occurs it won’t throw but returns an error property.

This sounds more like the behaviour you're looking for. Unfortunately, we don't currently expose FS.analyzePath on the webr object, but we can do so in a future release of webR.

@georgestagg georgestagg added the feature New feature or request label Jan 22, 2025
@Dual-Ice
Copy link
Author

It will be great if you perform this feature :)

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

No branches or pull requests

2 participants