Package com.jcraft.jsch

Examples of com.jcraft.jsch.SftpATTRS


 
  public long isFile(String file) throws Exception{
    long size = -1;
    try{
      //  Stat the requested site root
      SftpATTRS a = m_channel.stat(file);
     
      //  If file, great, return it's filesize, otherwise return -1
      //  If doesnt exist, throw exception
      if(a.isDir() == false) size = a.getSize();
    }catch(SftpException e){
      throw new Exception();
    }
   
    return size;
View Full Code Here


    public void execute() throws IOException, JSchException {
        ChannelSftp channel = openSftpChannel();
        try {
            channel.connect();
            try {
                SftpATTRS attrs = channel.stat(remoteFile);
                if (attrs.isDir() && !remoteFile.endsWith("/")) {
                    remoteFile = remoteFile + "/";
                }
            } catch (SftpException ee) {
                // Ignored
            }
View Full Code Here

    private void mkdir( String dir, int mode )
        throws TransferFailedException, SftpException
    {
        try
        {
            SftpATTRS attrs = channel.stat( dir );
            if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
            {
                throw new TransferFailedException( "Remote path is not a directory: " + dir );
            }
        }
        catch ( SftpException e )
View Full Code Here

    private SftpATTRS changeToRepositoryDirectory( String dir, String filename )
        throws ResourceDoesNotExistException, SftpException
    {
        // This must be called first to ensure that if the file doesn't exist it throws an exception
        SftpATTRS attrs;
        try
        {
            channel.cd( repository.getBasedir() );

            if ( dir.length() > 0 )
View Full Code Here

            dir = dir.substring( 1 );
        }

        try
        {
            SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );
            if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
            {
                throw new TransferFailedException( "Remote path is not a directory:" + dir );
            }

            @SuppressWarnings( "unchecked" )
View Full Code Here

            dir = dir.substring( 1 );
        }

        try
        {
            SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );

            long lastModified = attrs.getMTime() * MILLIS_PER_SEC;
            resource.setContentLength( attrs.getSize() );

            resource.setLastModified( lastModified );
           
            inputData.setInputStream( channel.get( filename ) );
        }
View Full Code Here

    }

    @Override
    FileStream open(final String path) throws IOException {
      try {
        final SftpATTRS a = ftp.lstat(path);
        return new FileStream(ftp.get(path), a.getSize());
      } catch (SftpException je) {
        if (je.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
          throw new FileNotFoundException(path);
        throw new TransportException("Can't get " + objectsPath + "/" //$NON-NLS-2$
            + path + ": " + je.getMessage(), je); //$NON-NLS-1$
View Full Code Here

    public void execute() throws IOException, JSchException {
        ChannelSftp channel = openSftpChannel();
        try {
            channel.connect();
            try {
                SftpATTRS attrs = channel.stat(remoteFile);
                if (attrs.isDir() && !remoteFile.endsWith("/")) {
                    remoteFile = remoteFile + "/";
                }
            } catch (SftpException ee) {
                // Ignored
            }
View Full Code Here

            if (r != null) {
                for (Iterator iter = r.iterator(); iter.hasNext();) {
                    Object obj = iter.next();
                    if (obj instanceof LsEntry) {
                        LsEntry entry = (LsEntry) obj;
                        SftpATTRS attrs = entry.getAttrs();
                        return new BasicResource(path, true, attrs.getSize(), attrs.getMTime()
                                * MILLIS_PER_SECOND, false);
                    }
                }
            }
        } catch (Exception e) {
View Full Code Here

        }
    }

    private void mkdirs(String directory, ChannelSftp c) throws IOException, SftpException {
        try {
            SftpATTRS att = c.stat(directory);
            if (att != null) {
                if (att.isDir()) {
                    return;
                }
            }
        } catch (SftpException ex) {
            if (directory.indexOf('/') != -1) {
View Full Code Here

TOP

Related Classes of com.jcraft.jsch.SftpATTRS

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.