Package com.jcraft.jsch

Examples of com.jcraft.jsch.ChannelSftp$LsEntrySelector


        }
    }

    public void get(String source, File destination) throws IOException {
        fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
        ChannelSftp c = getSftpChannel(source);
        try {
            String path = getPath(source);
            c.get(path, destination.getAbsolutePath(), new MyProgressMonitor());
        } catch (SftpException e) {
            IOException ex = new IOException("impossible to get " + source + " on " + getHost()
                    + (e.getMessage() != null ? ": " + e.getMessage() : ""));
            ex.initCause(e);
            throw ex;
View Full Code Here


        }
    }

    public void put(File source, String destination, boolean overwrite) throws IOException {
        fireTransferInitiated(getResource(destination), TransferEvent.REQUEST_PUT);
        ChannelSftp c = getSftpChannel(destination);
        try {
            String path = getPath(destination);
            if (!overwrite && checkExistence(path, c)) {
                throw new IOException("destination file exists and overwrite == false");
            }
            if (path.indexOf('/') != -1) {
                mkdirs(path.substring(0, path.lastIndexOf('/')), c);
            }
            c.put(source.getAbsolutePath(), path, new MyProgressMonitor());
        } catch (SftpException e) {
            IOException ex = new IOException(e.getMessage());
            ex.initCause(e);
            throw ex;
        } catch (URISyntaxException e) {
View Full Code Here

        return result;
    }

    public List list(String parent) throws IOException {
        try {
            ChannelSftp c = getSftpChannel(parent);
            String path = getPath(parent);
            Collection r = c.ls(path);
            if (r != null) {
                if (!path.endsWith("/")) {
                    path = parent + "/";
                }
                List result = new ArrayList();
View Full Code Here

     *             if any connection problem occurs
     */
    private ChannelSftp getSftpChannel(String pathOrUri) throws IOException {
        Session session = getSession(pathOrUri);
        String host = session.getHost();
        ChannelSftp channel = SshCache.getInstance().getChannelSftp(session);
        if (channel == null) {
            try {
                channel = (ChannelSftp) session.openChannel("sftp");
                channel.connect();
                Message.verbose(":: SFTP :: connected to " + host + "!");
                SshCache.getInstance().attachChannelSftp(session, channel);
            } catch (JSchException e) {
                IOException ex = new IOException(e.getMessage());
                ex.initCause(e);
View Full Code Here

        });
        return session;
    }

    public ChannelSftp createChannelSftp(Session session) throws JSchException {
        final ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
        return channel;
    }
View Full Code Here

        }

        try
        {
            // Use the pooled channel, or create a new one
            final ChannelSftp channel;
            if (idleChannel != null)
            {
                channel = idleChannel;
                idleChannel = null;
            }
            else
            {
                channel = (ChannelSftp) session.openChannel("sftp");
                channel.connect();

                Boolean userDirIsRoot = SftpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(getFileSystemOptions());
                String workingDirectory = getRootName().getPath();
                if (workingDirectory != null && (userDirIsRoot == null || !userDirIsRoot.booleanValue()))
                {
                    try
                    {
                        channel.cd(workingDirectory);
                    }
                    catch (SftpException e)
                    {
                        throw new FileSystemException("vfs.provider.sftp/change-work-directory.error", workingDirectory);
                    }
View Full Code Here

  /**
   * Fetches file attrs from server.
   */
  private void statSelf() throws Exception
  {
    ChannelSftp channel = fileSystem.getChannel();
    try
    {
      setStat(channel.stat(relPath));
    }
    catch (final SftpException e)
    {
      try
      {
        // maybe the channel has some problems, so recreate the channel and retry
        if (e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE)
        {
          channel.disconnect();
          channel = fileSystem.getChannel();
          setStat(channel.stat(relPath));
        }
        else
        {
          // Really does not exist
          attrs = null;
View Full Code Here

  /**
   * Creates this file as a folder.
   */
  protected void doCreateFolder() throws Exception
  {
    final ChannelSftp channel = fileSystem.getChannel();
    try
    {
      channel.mkdir(relPath);
    }
    finally
    {
      fileSystem.putChannel(channel);
    }
View Full Code Here

   *            times with nanosecond precision but at the moment jsch send
   *            them with second precision.
   */
  protected void doSetLastModifiedTime(final long modtime) throws Exception
  {
    final ChannelSftp channel = fileSystem.getChannel();
    try
    {
      int newMTime = (int) (modtime / 1000L);

      attrs.setACMODTIME(attrs.getATime(), newMTime);
      channel.setStat(relPath, attrs);
    }
    finally
    {
      fileSystem.putChannel(channel);
    }
View Full Code Here

  /**
   * Deletes the file.
   */
  protected void doDelete() throws Exception
  {
    final ChannelSftp channel = fileSystem.getChannel();
    try
    {
      if (getType() == FileType.FILE)
      {
        channel.rm(relPath);
      }
      else
      {
        channel.rmdir(relPath);
      }
    }
    finally
    {
      fileSystem.putChannel(channel);
View Full Code Here

TOP

Related Classes of com.jcraft.jsch.ChannelSftp$LsEntrySelector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.