当前位置: 首页>>代码示例>>Java>>正文


Java SftpATTRS.isDir方法代码示例

本文整理汇总了Java中com.jcraft.jsch.SftpATTRS.isDir方法的典型用法代码示例。如果您正苦于以下问题:Java SftpATTRS.isDir方法的具体用法?Java SftpATTRS.isDir怎么用?Java SftpATTRS.isDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jcraft.jsch.SftpATTRS的用法示例。


在下文中一共展示了SftpATTRS.isDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStatInfo

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
private StatInfo createStatInfo(String dirName, String baseName, SftpATTRS attrs, ChannelSftp cftp) throws SftpException {
    String linkTarget = null;
    if (attrs.isLink()) {
        String path = dirName + '/' + baseName;
        RemoteStatistics.ActivityID activityID = RemoteStatistics.startChannelActivity("readlink", path); // NOI18N
        try {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "performing readlink {0}", path);
            }
            linkTarget = cftp.readlink(path);
        } finally {
            RemoteStatistics.stopChannelActivity(activityID);
        }
    }
    Date lastModified = new Date(attrs.getMTime() * 1000L);
    StatInfo result = new FileInfoProvider.StatInfo(baseName, attrs.getUId(), attrs.getGId(), attrs.getSize(),
            attrs.isDir(), attrs.isLink(), linkTarget, attrs.getPermissions(), lastModified);
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SftpSupport.java

示例2: LsEntry2EncFSFileInfo

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
private EncFSFileInfo LsEntry2EncFSFileInfo(String parentPath, LsEntry file){
	EncFSFileInfo result;
	try {
		String name = file.getFilename();

		SftpATTRS attrs = file.getAttrs();
           long mtime = attrs.getMTime();		
           boolean isDir = attrs.isDir();
           long length = attrs.getSize();
		String relativePath=this.getRelativePathFromAbsolutePath(parentPath);
           
		
		
		if (name.endsWith("/")) name=name.substring(0,name.length()-1);
		result = new EncFSFileInfo(name,relativePath,isDir,mtime,length,true,true,true);
		
	} catch (Exception e){
		throw new RuntimeException(e);
	}
	
	return result;
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:23,代码来源:FileProvider6.java

示例3: getFileStatus

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
/**
 * Convert the file information in LsEntry to a {@link FileStatus} object. *
 *
 * @param sftpFile
 * @param parentPath
 * @return file status
 * @throws IOException
 */
private FileStatus getFileStatus(ChannelSftp channel, LsEntry sftpFile,
    Path parentPath) throws IOException {

  SftpATTRS attr = sftpFile.getAttrs();
  long length = attr.getSize();
  boolean isDir = attr.isDir();
  boolean isLink = attr.isLink();
  if (isLink) {
    String link = parentPath.toUri().getPath() + "/" + sftpFile.getFilename();
    try {
      link = channel.realpath(link);

      Path linkParent = new Path("/", link);

      FileStatus fstat = getFileStatus(channel, linkParent);
      isDir = fstat.isDirectory();
      length = fstat.getLen();
    } catch (Exception e) {
      throw new IOException(e);
    }
  }
  int blockReplication = 1;
  // Using default block size since there is no way in SFTP channel to know of
  // block sizes on server. The assumption could be less than ideal.
  long blockSize = DEFAULT_BLOCK_SIZE;
  long modTime = attr.getMTime() * 1000; // convert to milliseconds
  long accessTime = 0;
  FsPermission permission = getPermissions(sftpFile);
  // not be able to get the real user group name, just use the user and group
  // id
  String user = Integer.toString(attr.getUId());
  String group = Integer.toString(attr.getGId());
  Path filePath = new Path(parentPath, sftpFile.getFilename());

  return new FileStatus(length, isDir, blockReplication, blockSize, modTime,
      accessTime, permission, user, group, filePath.makeQualified(
          this.getUri(), this.getWorkingDirectory()));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:47,代码来源:SFTPFileSystem.java

示例4: SFTPFile2

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public SFTPFile2(SftpATTRS stat, String filename, Uri uri) {
    if (filename == null){
        throw new IllegalArgumentException("filename cannot be null");
    }
    if (uri == null) {
        throw new IllegalArgumentException("uri cannot be null");
    }

    mUriString = uri.toString();
    mName = filename;
    mIsDirectory = stat.isDir();
    mIsFile = !stat.isDir();
    mLastModified = stat.getMTime();
    //TODO : permissions
    mCanRead = true;
    mCanWrite = true;
    mLength = stat.getSize();
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:19,代码来源:SFTPFile2.java

示例5: _buildFiles

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
private List<FileBean> _buildFiles(Vector ls,String dir) throws Exception {  
    if (ls != null && ls.size() >= 0) {  
        List<FileBean> list = new ArrayList<FileBean>();
        for (int i = 0; i < ls.size(); i++) {  
            LsEntry f = (LsEntry) ls.get(i);  
            String nm = f.getFilename();  
            
            if (nm.equals(".") || nm.equals(".."))  
                continue;  
            SftpATTRS attr = f.getAttrs();  
            FileBean fileBean=new FileBean();
            if (attr.isDir()) {  
                fileBean.setDir(true);
            } else {  
                fileBean.setDir(false);
            }  
            fileBean.setAttrs(attr);
            fileBean.setFilePath(dir);
            fileBean.setFileName(nm);
            list.add(fileBean);  
        }  
        return list;  
    }  
    return null;  
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:26,代码来源:SFTPUtil.java

示例6: existsDirectory

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
/**
     * Determines whether a directory exists or not
     * 如果是文件,也会抛出异常,返回 false
     *
     * @param remoteDirectoryPath
     * @return true if exists, false otherwise
     * @throws IOException thrown if any I/O error occurred.
     */
    @Override
    public boolean existsDirectory(String remoteDirectoryPath) {

        try {
            // System.out.println(channel.realpath(remoteFilePath));
            SftpATTRS attrs = channel.stat(remoteDirectoryPath);
            return attrs.isDir();
        } catch (SftpException e) {
            // e.printStackTrace();
            return false;
        }


//        String originalWorkingDirectory = getWorkingDirectory();
//        try {
//            changeDirectory(remoteDirectoryPath);
//        } catch (FtpException e) {
//            //文件夹不存在,会抛出异常。
//            return false;
//        }
//        //恢复 ftpClient 当前工作目录属性
//        changeDirectory(originalWorkingDirectory);
//        return true;
    }
 
开发者ID:h819,项目名称:spring-boot,代码行数:33,代码来源:SftpConnection.java

示例7: traverse

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
/**
 * Delete directory and its content recursively.
 * 
 * @param channel
 *            open channel to SFTP server
 * @param path
 *            path of the directory
 * @throws SftpException
 *             when something went wrong
 */
@SuppressWarnings("unchecked")
private void traverse(ChannelSftp channel, String path)
        throws SftpException {
    SftpATTRS attrs = channel.stat(path);
    if (attrs.isDir()) {
        Vector<LsEntry> files = channel.ls(path);
        if (files != null && files.size() > 0) {
            Iterator<LsEntry> it = files.iterator();
            while (it.hasNext()) {
                LsEntry entry = it.next();
                if ((!entry.getFilename().equals(".")) && (!entry.getFilename().equals(".."))) {
                    traverse(channel, path + "/" + entry.getFilename());
                }
            }
        }
        channel.rmdir(path);
    } else {
        channel.rm(path);
    }
}
 
开发者ID:psnc-dl,项目名称:darceo,代码行数:31,代码来源:SftpDataStorageClient.java

示例8: getFileType

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:18,代码来源:SFTPClient.java

示例9: folderExists

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
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;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:17,代码来源:SFTPClient.java

示例10: folderExists

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
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;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:17,代码来源:SFTPClient.java

示例11: getFileType

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
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 );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:SFTPClient.java

示例12: folderExists

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
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;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:SFTPClient.java

示例13: setFromAttrs

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
private void setFromAttrs(FileEntry fileEntry, SftpATTRS attrs) {
	fileEntry.isDirectory = attrs.isDir();
	fileEntry.canRead = true; // currently not inferred from the
								// permissions.
	fileEntry.canWrite = true; // currently not inferred from the
								// permissions.
	fileEntry.lastModifiedTime = ((long) attrs.getMTime()) * 1000;
	if (fileEntry.isDirectory)
		fileEntry.sizeInBytes = 0;
	else
		fileEntry.sizeInBytes = attrs.getSize();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:13,代码来源:SftpStorage.java

示例14: isDir

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public boolean isDir(String targetDir) throws SftpException {
	try {
		SftpATTRS attrs = channelSftp.stat(targetDir);
		return attrs.isDir();
	} catch (SftpException sftpException) {
		return false;
	}
}
 
开发者ID:gchq,项目名称:stroom-agent,代码行数:9,代码来源:SFTPTransfer.java

示例15: isDir

import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
private boolean isDir(String path) {
    ChannelSftp sftp = getSftpChannel();
    try {
        SftpATTRS attrs = sftp.stat(path);
        return attrs.isDir();
    } catch (SftpException e) {
        throw new SshException(e);
    }
}
 
开发者ID:huiyu,项目名称:ssh4j,代码行数:10,代码来源:SshClient.java


注:本文中的com.jcraft.jsch.SftpATTRS.isDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。