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

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

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

class FTPSContext implements Closeable {

    final FTPSFileSystemProvider provider;

    final FileSystem fileSystem;

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

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