1 package org
.argeo
.cms
.ssh
;
3 import java
.io
.IOException
;
5 import java
.nio
.file
.FileSystem
;
6 import java
.nio
.file
.Path
;
8 import org
.apache
.sshd
.sftp
.client
.fs
.SftpFileSystem
;
10 /** Create an SFTP {@link FileSystem}. */
11 public class Sftp
extends AbstractSsh
{
14 private SftpFileSystem fileSystem
;
16 public Sftp(String username
, String host
, int port
) {
17 this(AbstractSsh
.toUri(username
, host
, port
));
20 public Sftp(URI uri
) {
25 public FileSystem
getFileSystem() {
26 if (fileSystem
== null) {
29 fileSystem
= getSftpFileSystemProvider().newFileSystem(getSession());
30 } catch (IOException e
) {
31 throw new IllegalStateException(e
);
37 public Path
getBasePath() {
38 String p
= uri
.getPath() != null ? uri
.getPath() : "/";
39 return getFileSystem().getPath(p
);