No description, website, or topics provided.
Java
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE.txt
README.md
pom.xml

README.md

fswrap

(c) 2012 University of Manchester, UK support@mygrid.org.uk

Licensed under the GNU Lesser General Public License (LGPL) 2.1. See LICENSE.txt for the full terms of LGPL 2.1.

This is a FileSystemProvider for the Java NIO.2 API that allows wrapping calls to an existing file system, for instance for the purpose of logging, tracing paths in a manifest, etc.

Requisites

  • Java 1.7 or newer
  • Maven 3.0 or newer (for building)

Building

  • mvn clean install

Usage

The uk.org.taverna.fswrap.WrappedFileSystemProvider should automatically be registered under the URI scheme "wrap".

For instance, to wrap the default file system:

URI uri = URI.create("wrap:file:///");
try (FileSystem fs = FileSystems.newFileSystem(uri, env)) {
    Path p = fs.getPath("tmp", "file.txt");
    Files.createFile(p);
}

Or using this convenience method:

try (WrappedFileSystem fs = WrappedFileSystemProvider.wrapDefaultFs()) {
    Path p = fs.getPath("tmp", "file.txt");
    Files.createFile(p);
}

To register to listen for events occurring through the WrappedFileSystem (Note: not done directly on original file system):

 listener = new uk.org.taverna.fswrap.FileSystemEventListener() {
     @Override
     public void copied(Path source, Path target, CopyOption[] options) {
         System.out.println("copied " + source + " to " + target);
     }
     // ....
 };
 fs.provider().addFileSystemEventListener(listener);

You may want to use the uk.org.taverna.fswrap.FileSystemEventAdapter as a superclass if you are not interested in every captured event.

Note that in the current version of this library the listener will be informed of operations on any file systems wrapped using WrappedFileSystemProvider.