@Override public boolean accept(LsEntry t) { return t.getAttrs().isDir(); } });
@Override public boolean accept(LsEntry t) { return t.getAttrs().isDir(); } });
@Override public boolean accept(LsEntry t) { return false == t.getAttrs().isDir(); } });
@Override public boolean accept(LsEntry t) { return false == t.getAttrs().isDir(); } });
public String[] dir() throws KettleJobException { 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 KettleJobException( e ); } return fileList; }
if ((recurse && entry.getAttrs().isDir()) || (symlink && entry.getAttrs().isLink())){ subDirs.add(entry); return LsEntrySelector.CONTINUE; if (!entry.getAttrs().isDir() && !entry.getAttrs().isLink() && isPathMatch) { if (pattern == null || pattern.matcher(entryFilename).matches()) { listing.add(newFileInfo(entry, path));
public boolean folderExists( String foldername ) { boolean retval = false; try { SftpATTRS attrs = c.stat( foldername ); if ( attrs == null ) { return false; } if ( ( attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS ) == 0 ) { throw new KettleJobException( "Unknown permissions error" ); } retval = attrs.isDir(); } catch ( Exception e ) { // Folder can not be found! } return retval; }
public FileType getFileType( String filename ) throws KettleJobException { try { SftpATTRS attrs = c.stat( filename ); if ( attrs == null ) { return FileType.IMAGINARY; } if ( ( attrs.getFlags() & SftpATTRS.SSH_FILEXFER_ATTR_PERMISSIONS ) == 0 ) { throw new KettleJobException( "Unknown permissions error" ); } if ( attrs.isDir() ) { return FileType.FOLDER; } else { return FileType.FILE; } } catch ( Exception e ) { throw new KettleJobException( e ); } }
boolean isDir = attr.isDir(); boolean isLink = attr.isLink(); if (isLink) {
@Override public FileStatus getFileStatus(Path path) throws IOException { ChannelSftp channelSftp = null; ChannelExec channelExec1 = null; ChannelExec channelExec2 = null; try { channelSftp = this.fsHelper.getSftpChannel(); SftpATTRS sftpAttrs = channelSftp.stat(HadoopUtils.toUriPath(path)); FsPermission permission = new FsPermission((short) sftpAttrs.getPermissions()); channelExec1 = this.fsHelper.getExecChannel("id " + sftpAttrs.getUId()); String userName = IOUtils.toString(channelExec1.getInputStream()); channelExec2 = this.fsHelper.getExecChannel("id " + sftpAttrs.getGId()); String groupName = IOUtils.toString(channelExec2.getInputStream()); FileStatus fs = new FileStatus(sftpAttrs.getSize(), sftpAttrs.isDir(), 1, 0l, sftpAttrs.getMTime(), sftpAttrs.getATime(), permission, StringUtils.trimToEmpty(userName), StringUtils.trimToEmpty(groupName), path); return fs; } catch (SftpException e) { throw new IOException(e); } finally { safeDisconnect(channelSftp); safeDisconnect(channelExec1); safeDisconnect(channelExec2); } }
private FileInfo newFileInfo(final LsEntry entry, String path) { if (entry == null) { return null; } final File newFullPath = new File(path, entry.getFilename()); final String newFullForwardPath = newFullPath.getPath().replace("\\", "/"); String perms = entry.getAttrs().getPermissionsString(); if (perms.length() > 9) { perms = perms.substring(perms.length() - 9); } FileInfo.Builder builder = new FileInfo.Builder() .filename(entry.getFilename()) .fullPathFileName(newFullForwardPath) .directory(entry.getAttrs().isDir()) .size(entry.getAttrs().getSize()) .lastModifiedTime(entry.getAttrs().getMTime() * 1000L) .permissions(perms) .owner(Integer.toString(entry.getAttrs().getUId())) .group(Integer.toString(entry.getAttrs().getGId())); return builder.build(); }
fileName = entry.getFilename(); if (false == fileName.equals(".") && false == fileName.equals("..")) { if (entry.getAttrs().isDir()) { delDir(fileName); } else {
fileName = entry.getFilename(); if (false == fileName.equals(".") && false == fileName.equals("..")) { if (entry.getAttrs().isDir()) { delDir(fileName); } else {
/** * @see com.jcraft.jsch.SftpATTRS#isDir() */ @Override public boolean isDirectory() { return this.attrs.isDir(); }
@Override protected boolean isDirectory(LsEntry file) { return file.getAttrs().isDir(); }
@Override protected boolean isDirectory(LsEntry file) { return file.getAttrs().isDir(); }
@Override protected boolean isDirectory(LsEntry file) { return file.getAttrs().isDir(); }
@Override protected boolean isDirectory(LsEntry file) { return file != null && file.getAttrs().isDir(); }
@Override public String[] listNames(String path) throws IOException { LsEntry[] entries = this.list(path); List<String> names = new ArrayList<String>(); for (int i = 0; i < entries.length; i++) { String fileName = entries[i].getFilename(); SftpATTRS attrs = entries[i].getAttrs(); if (!attrs.isDir() && !attrs.isLink()) { names.add(fileName); } } String[] fileNames = new String[names.size()]; return names.toArray(fileNames); }
@Override protected boolean isFile(LsEntry file) { return (file != null && file.getAttrs() != null && !file.getAttrs().isDir() && !file.getAttrs().isLink()); }