package org.xbib.files.ftp.fs.spi;

import org.xbib.files.ftp.fs.FTPEnvironment;
import org.xbib.files.ftp.fs.FTPFileSystemProvider;

import java.io.Closeable;
import java.io.IOException;
import java.net.URI;
import java.nio.file.FileSystem;
import java.util.Map;

class FTPContext implements Closeable {

    final FTPFileSystemProvider provider;

    final FileSystem fileSystem;

    FTPContext(URI uri, Map<String, ?> env) throws IOException {
        this.provider = new FTPFileSystemProvider();
        this.fileSystem = provider.newFileSystem(uri, env != null ? env : new FTPEnvironment());
    }

    @Override
    public void close() throws IOException {
        fileSystem.close();
    }
}
