use of com.jcraft.jsch.SftpException in project linuxtools by eclipse.
the class SSHFileStore method fetchInfo.
@Override
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(Messages.SSHFileStore_attrMonitor, 100);
ChannelSftp channel = proxy.getChannelSftp();
monitor.worked(25);
SftpATTRS attrs = channel.stat(uri.getPath());
monitor.worked(100);
monitor.done();
return createFileInfo(attrs);
} catch (SftpException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_attrFailed + e.getMessage()));
}
}
use of com.jcraft.jsch.SftpException in project linuxtools by eclipse.
the class SSHFileStore method childStores.
@Override
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(Messages.SSHFileStore_childStoresMonitor, 100);
ChannelSftp channel = proxy.getChannelSftp();
monitor.worked(25);
Vector<?> v = channel.ls(uri.getPath());
monitor.worked(50);
LinkedList<IFileStore> childs = new LinkedList<>();
boolean isDir = false;
for (int i = 0; i < v.size(); i++) {
ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
if (// $NON-NLS-1$ //$NON-NLS-2$
!entry.getFilename().equals(".") && !entry.getFilename().equals(".."))
childs.add(createFileStore(path.append(entry.getFilename()).toString()));
else
isDir = true;
}
if (!isDir)
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.SSHFileStore_childStoresFailedDirectory, getName())));
monitor.worked(100);
monitor.done();
return childs.toArray(new IFileStore[0]);
} catch (SftpException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childStoresFailed + e.getMessage()));
}
}
use of com.jcraft.jsch.SftpException in project linuxtools by eclipse.
the class SSHFileStore method childInfos.
@Override
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try {
monitor.beginTask(Messages.SSHFileStore_childInfoMonitor, 100);
ChannelSftp channel = proxy.getChannelSftp();
monitor.worked(25);
Vector<?> v = channel.ls(uri.getPath());
monitor.worked(50);
LinkedList<IFileInfo> childs = new LinkedList<>();
boolean isDir = false;
for (int i = 0; i < v.size(); i++) {
ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) {
// $NON-NLS-1$ //$NON-NLS-2$
childs.add(createFileInfo(entry.getAttrs()));
} else {
isDir = true;
}
}
if (!isDir) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.SSHFileStore_childInfoFailedDirectory, getName())));
}
monitor.worked(100);
monitor.done();
return childs.toArray(new IFileInfo[0]);
} catch (SftpException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childInfoFailed + e.getMessage()));
}
}
use of com.jcraft.jsch.SftpException in project linuxtools by eclipse.
the class SSHFileStore method childNames.
@Override
public String[] childNames(int options, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try {
monitor.beginTask(Messages.SSHFileStore_childNamesMonitor, 100);
ChannelSftp channel = proxy.getChannelSftp();
monitor.worked(25);
Vector<?> v = channel.ls(uri.getPath());
monitor.worked(50);
LinkedList<String> childs = new LinkedList<>();
boolean isDir = false;
for (int i = 0; i < v.size(); i++) {
ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) v.get(i);
if (!entry.getFilename().equals(".") && !entry.getFilename().equals("..")) {
// $NON-NLS-1$ //$NON-NLS-2$
childs.add(entry.getFilename());
} else {
isDir = true;
}
}
if (!isDir) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format(Messages.SSHFileStore_childNamesFailedDirectory, getName())));
}
monitor.worked(100);
monitor.done();
return childs.toArray(new String[0]);
} catch (SftpException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SSHFileStore_childNamesFailed + e.getMessage()));
}
}
use of com.jcraft.jsch.SftpException in project javautils by jiadongpo.
the class SFTPClient method dir.
public String[] dir() throws Exception {
String[] fileList = null;
try {
java.util.Vector<?> v = c.ls(".");
java.util.Vector<String> o = new java.util.Vector<String>();
if (v != null) {
for (int i = 0; i < v.size(); i++) {
Object obj = v.elementAt(i);
if (obj != null && obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry) {
LsEntry lse = (com.jcraft.jsch.ChannelSftp.LsEntry) obj;
if (!lse.getAttrs().isDir())
o.add(lse.getFilename());
}
}
}
if (o.size() > 0) {
fileList = new String[o.size()];
o.copyInto(fileList);
}
} catch (SftpException e) {
throw new Exception(e);
}
return fileList;
}
Aggregations