javafs icon indicating copy to clipboard operation
javafs copied to clipboard

Make ErrorCodes publicly accessable

Open dinocore1 opened this issue 9 years ago • 6 comments

I am trying to implement a subclass of AbstractFuseFilesystem and need to be able to return error codes. For example:

protected synchronized int readdir(String path, StructFuseFileInfo info, DirectoryFiller filler) {
        if(!mVirtualFS.pathExists(path)) {
            return -ErrorCodes.ENOENT();
        }

dinocore1 avatar Aug 21 '16 20:08 dinocore1

May I ask why do you need to subclass AbstractFuseFilesystem? It kind of goes against the whole spirit of this project, which attempts to hide FUSE altogether, instead exposing only Java's FileSystem as the only API.

pron avatar Aug 22 '16 12:08 pron

It wasn't obvious how to get started with the Java FileSystem API. Is there any example code on how to use the JavaFS + the FileSystem API? It seemed more straight forward to subclass AbstractFuseFilesystem. Also, I'm not sure yet, but my project might require this kind of low-level and fine control.

I would be happy to add some documentation to the README.md

dinocore1 avatar Aug 22 '16 14:08 dinocore1

The entire documentation is there, and that's the whole point of the project :)

JavaFS has only two API methods: JavaFS.mount and JavaFS.unmount. The FileSystem API/SPI is fully documented in the Java documentation. For a direct FUSE API, consider using one of the alternative projects listed in README.

pron avatar Aug 22 '16 14:08 pron

In other words, you don't return an error code, but throw an appropriate exception.

pron avatar Aug 22 '16 14:08 pron

Ah I see. I actually started by using jnr-fuse but it did not have support for Mac OSX. JavaFS's Mac OSX supports works perfectly, that why I chose to use it.

dinocore1 avatar Aug 22 '16 17:08 dinocore1

The FileSystemProvider SPI is actually quite good and quite portable. If it's good enough for your needs, then this is the project for you. You can find implementations for a ZIP file system and an in-memory file system.

pron avatar Aug 22 '16 17:08 pron