I need a virtual file system that a directory of host file system as its own root. Whatever path the VFS is asked to resolve, it should never go beyond the specified directory host's directory. For example:
FileSystem fs = new CustomFileSystem(Paths.of("/some/directory/path")) // a real directory in host's FS.
fs.getPath("./test") // "/some/directory/path/test"
fs.getPath("/") // "/some/directory/path"
fs.getPath("../../test") // "/some/directory/path/test" not "/some/test"
I looked and the standard FileSystems.newFileSystem()
but it seems to be working with files only. Same does Apache Commons VFS. It just extends the number of supported archive formats.
Is there any standard way to create such vfs, or the only way is custom implementation of FileSystem
or/and FileSystemProvider
?