use of gov.sandia.n2a.host.SshFileSystem.WrapperSftp in project n2a by frothga.
the class SshFileSystemProvider method createDirectory.
public void createDirectory(Path dir, FileAttribute<?>... attributes) throws IOException {
SshPath A = (SshPath) dir;
String name = A.toAbsolutePath().toString();
try {
WrapperSftp sftp = A.getSftp();
sftp.mkdir(name);
applyAttributes(A, attributes);
} catch (SftpException e) {
// so the following conclusion might not be accurate ...
if (e.id == ChannelSftp.SSH_FX_FAILURE)
throw new FileAlreadyExistsException(name);
throw new IOException(e);
}
}
use of gov.sandia.n2a.host.SshFileSystem.WrapperSftp in project n2a by frothga.
the class SshFileSystemProvider method delete.
public void delete(Path path) throws IOException {
String name = path.toAbsolutePath().toString();
try {
WrapperSftp sftp = ((SshPath) path).getSftp();
// doesn't follow links
SftpATTRS attributes = sftp.lstat(name);
if (attributes.isDir())
sftp.rmdir(name);
else
sftp.rm(name);
} catch (SftpException e) {
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
throw new NoSuchFileException(name);
throw new IOException(e);
}
}
Aggregations