How to properly clear VFS Ram filesystem

1.4k Views Asked by At

I'm using VFS2 to construct an in-memory filesystem (uring the ram scheme) for tests. After each test I've to clean up (destroy all created files and folders), I'm using the following command:

VFS.getManager().getFilesCache().close();

However this doesn't seem to clear everything! what's the proper way to do it?

1

There are 1 best solutions below

2
On BEST ANSWER

According to the Javadoc FileCache only closes the cache.

FileSystemManager manager = VFS.getManager();
FileObject root = manager.resolveFile("ram:/");
manager.closeFileSystem(root.getFileSystem());

The last line clears the filecache of the filesystem and will close the filesystem passed in