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


Java ChannelSftp.lstat方法代码示例

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


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

示例1: SshToolInvocation

import com.jcraft.jsch.ChannelSftp; //导入方法依赖的package包/类
public SshToolInvocation(ToolDescription desc, SshNode workerNodeA,
		AskUserForPw askUserForPwA, CredentialManager credentialManager)
		throws JSchException, SftpException {
	this.workerNode = workerNodeA;
	this.credentialManager = credentialManager;

	setRetrieveData(workerNodeA.isRetrieveData());
	this.askUserForPw = askUserForPwA;
	usecase = desc;

	ChannelSftp sftp = SshPool.getSftpPutChannel(workerNode, askUserForPw);
	synchronized (getNodeLock(workerNode)) {

		logger.info("Changing remote directory to "
				+ workerNode.getDirectory());
		sftp.cd(workerNode.getDirectory());
		Random rnd = new Random();
		while (true) {
			tmpname = "usecase" + rnd.nextLong();
			try {
				sftp.lstat(workerNode.getDirectory() + tmpname);
				continue;
			} catch (Exception e) {
				// file seems to not exist :)
			}
			sftp.mkdir(workerNode.getDirectory() + tmpname);
			sftp.cd(workerNode.getDirectory() + tmpname);
			break;
		}
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:32,代码来源:SshToolInvocation.java

示例2: createUniqueFileName

import com.jcraft.jsch.ChannelSftp; //导入方法依赖的package包/类
private String createUniqueFileName(ChannelSftp sftp, String remotePath, String name, String extension) {
    String mName = name;
    int length = 1;
    while (true) {
        try {
            sftp.lstat(remotePath + mName + extension);
        } catch (SftpException e) {

            break;
        }

        mName = mName + randomIdentifier(length);
        length++;
    }
    return mName;
}
 
开发者ID:davols,项目名称:android-light-dasftp,代码行数:17,代码来源:ImageHandler.java

示例3: lstat

import com.jcraft.jsch.ChannelSftp; //导入方法依赖的package包/类
/**
 * This method returns the file attributes of the remote file.
 *
 * @param session JSch session
 * @param remoteFile Absolute path of the remote file
 * @return SftpATTRS object that contains the file attributes
 * @throws JSchException
 * @throws SftpException
 */
public static SftpATTRS lstat( Session session, String remoteFile )
    throws JSchException, SftpException
{
    ChannelSftp sftpChannel = (ChannelSftp) session.openChannel( "sftp" );
    sftpChannel.connect();
    SftpATTRS fileStat = sftpChannel.lstat( remoteFile );
    sftpChannel.disconnect();
    return fileStat;
}
 
开发者ID:vmware,项目名称:OHMS,代码行数:19,代码来源:SshUtil.java

示例4: lstat

import com.jcraft.jsch.ChannelSftp; //导入方法依赖的package包/类
/**
 * This method returns the file attributes of the remote file.
 * 
 * @param session JSch session
 * @param remoteFile Absolute path of the remote file
 * @return SftpATTRS object that contains the file attributes
 * @throws JSchException
 * @throws SftpException
 */
public static SftpATTRS lstat( Session session, String remoteFile )
    throws JSchException, SftpException
{
    ChannelSftp sftpChannel = (ChannelSftp) session.openChannel( "sftp" );
    sftpChannel.connect();
    SftpATTRS fileStat = sftpChannel.lstat( remoteFile );
    sftpChannel.disconnect();
    return fileStat;
}
 
开发者ID:vmware,项目名称:OHMS,代码行数:19,代码来源:SshUtil.java

示例5: setLastModified

import com.jcraft.jsch.ChannelSftp; //导入方法依赖的package包/类
private void setLastModified(final File localFile) throws JSchException {
    SftpATTRS fileAttributes = null;
    final ChannelSftp channel = openSftpChannel();
    channel.connect();
    try {
        fileAttributes = channel.lstat(remoteDir(remoteFile)
                                       + localFile.getName());
    } catch (final SftpException e) {
        throw new JSchException("failed to stat remote file", e);
    }
    FileUtils.getFileUtils().setFileLastModified(localFile,
                                                 ((long) fileAttributes
                                                  .getMTime())
                                                 * 1000);
}
 
开发者ID:apache,项目名称:ant,代码行数:16,代码来源:ScpFromMessage.java

示例6: call

import com.jcraft.jsch.ChannelSftp; //导入方法依赖的package包/类
@Override
public StatInfo call() throws IOException, CancellationException, JSchException, ExecutionException, InterruptedException, SftpException {
    if (!path.startsWith("/")) { //NOI18N
        throw new FileNotFoundException("Path is not absolute: " + path); //NOI18N
    }
    StatInfo result = null;
    SftpException exception = null;
    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "{0} started", getTraceName());
    }
    String threadName = Thread.currentThread().getName();
    Thread.currentThread().setName(PREFIX + ": " + getTraceName()); // NOI18N
    int attempt = 1;
    try {
        for (; attempt <= LS_RETRY_COUNT; attempt++) {
            ChannelSftp cftp = getChannel();
            RemoteStatistics.ActivityID activityID = RemoteStatistics.startChannelActivity("statload", path); // NOI18N
            try {
                SftpATTRS attrs = lstat ? cftp.lstat(path) : cftp.stat(path);
                String dirName, baseName;
                int slashPos = path.lastIndexOf('/');
                if (slashPos == 0) {
                    dirName = "";
                    baseName = path.substring(1);
                } else {
                    dirName = path.substring(0, slashPos);
                    baseName = path.substring(slashPos + 1);
                }
                result = createStatInfo(dirName, baseName, attrs, cftp);
                exception = null;
                break;
            } catch (SftpException e) {
                exception = e;
                if (e.id == SftpIOException.SSH_FX_FAILURE) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.log(Level.FINE, "{0} - exception while attempt {1}", new Object[]{getTraceName(), attempt});
                    }
                    if (MiscUtils.mightBrokeSftpChannel(e)) {
                        cftp.quit();
                    }
                } else {
                    // re-try in case of failure only
                    // otherwise consider this exception as unrecoverable
                    break;
                }
            } finally {
                RemoteStatistics.stopChannelActivity(activityID);
                releaseChannel(cftp);
            }
        }
    } finally {
        Thread.currentThread().setName(threadName);
    }

    if (exception != null) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, "{0} failed", getTraceName());
        }
        throw decorateSftpException(exception, path);
    }

    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, "{0} finished in {1} attempt(s)", new Object[]{getTraceName(), attempt});
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:67,代码来源:SftpSupport.java


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