Search in sources :

Example 1 with FileSystemAlreadyExistsException

use of java.nio.file.FileSystemAlreadyExistsException in project jimfs by google.

the class SystemJimfsFileSystemProvider method newFileSystem.

@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
    checkArgument(uri.getScheme().equalsIgnoreCase(URI_SCHEME), "uri (%s) scheme must be '%s'", uri, URI_SCHEME);
    checkArgument(isValidFileSystemUri(uri), "uri (%s) may not have a path, query or fragment", uri);
    checkArgument(env.get(FILE_SYSTEM_KEY) instanceof FileSystem, "env map (%s) must contain key '%s' mapped to an instance of %s", env, FILE_SYSTEM_KEY, FileSystem.class);
    FileSystem fileSystem = (FileSystem) env.get(FILE_SYSTEM_KEY);
    if (fileSystems.putIfAbsent(uri, fileSystem) != null) {
        throw new FileSystemAlreadyExistsException(uri.toString());
    }
    return fileSystem;
}
Also used : FileSystem(java.nio.file.FileSystem) FileSystemAlreadyExistsException(java.nio.file.FileSystemAlreadyExistsException)

Aggregations

FileSystem (java.nio.file.FileSystem)1 FileSystemAlreadyExistsException (java.nio.file.FileSystemAlreadyExistsException)1