Package com.sshtools.j2ssh.sftp

Examples of com.sshtools.j2ssh.sftp.FileAttributes


    try{
      //  Stat the item, if found directory or file, set the status
      //  This is an error, if the directory/file exists here, you can't
      //  create anything
      m_output.println("[ryan]directory = "+dir);
      FileAttributes attrib = m_sftp.stat(dir);
      m_output.println("[ryan]attrib = "+attrib+", attrib string = "+attrib.toString());
     
      if(attrib.isDirectory() == true){
        m_fileList.setStatus(m_count, FileList.DEXIST);
      }else{
        m_fileList.setStatus(m_count, FileList.FEXIST);
      }
    }catch(IOException e){
View Full Code Here


         
          //  Ignores anything with a . or .. in it
          if(entry.getFilename().endsWith(".")) continue;
          //m_output.println("[ryan]entry = "+entry+", entry filename = "+entry.getFilename());
          //  Get the attributes for this directory item
          FileAttributes attrib = entry.getAttributes();
          //m_output.println("[ryan]attrib = "+attrib+", attrib string = "+attrib.toString());
         
          //  Is it a directory or file? add it to the appropriate array
          if(attrib.isDirectory() == true && m_details.getRecurse() == true){
            folders.add(directory+entry.getFilename()+"/");
          }else{
            files.add(directory+entry.getFilename());
          }
        }
View Full Code Here

 
  public boolean isDirectory(String dir) throws Exception{
    m_output.println("TransferSSHTools::isDirectory(String dir)");
    try{
      //  Stat the requested site root
      FileAttributes attrib = m_sftp.stat(dir);
      m_output.println("[ryan]attrib = "+attrib+", attrib string = "+attrib.toString());
     
      //  If directory, great, otherwise, show warning
      if(attrib.isDirectory()) return true;
    }catch(IOException e){
      throw new Exception();
    }
   
    return false;
View Full Code Here

  public long isFile(String file) throws Exception{
    m_output.println("TransferSSHTools::isFile(String file)");
    long size = -1;
    try{
      //  Stat the requested site root
      FileAttributes attrib = m_sftp.stat(file);
      m_output.println("[ryan]attrib = "+attrib+", attrib string = "+attrib.toString());
     
      //  If file, great, return it's filesize, otherwise return -1
      //  If doesnt exist, throw exception
      if(attrib.isFile()) size = attrib.getSize().longValue();
    }catch(IOException e){
      throw new Exception();
    }
   
    return size;
View Full Code Here

            if (permissions == null) {
                throw new IOException("No default permissions set");
            }

            FileAttributes attrs = new FileAttributes();
            attrs.setSize(new UnsignedInteger64(String.valueOf(f.length())));
            attrs.setTimes(new UnsignedInteger32(f.lastModified() / 1000),
                new UnsignedInteger32(f.lastModified() / 1000));

            boolean canExec = true;

            try {
                if (System.getSecurityManager() != null) {
                    System.getSecurityManager().checkExec(f.getCanonicalPath());
                }
            } catch (SecurityException ex1) {
                canExec = false;
            }

            attrs.setPermissions((((f.canRead() && permissions.canRead()) ? "r"
                                                                          : "-") +
                ((f.canWrite() && permissions.canWrite()) ? "w" : "-") +
                ((canExec && permissions.canExecute()) ? "x" : "-")));
            attrs.setPermissions(new UnsignedInteger32(attrs.getPermissions()
                                                            .longValue() |
                    (f.isDirectory() ? FileAttributes.S_IFDIR
                                     : FileAttributes.S_IFREG)));

            return attrs;
View Full Code Here

        if (permissions == null) {
            throw new IOException("No default permissions set");
        }

        FileAttributes attrs = new FileAttributes();
        attrs.setSize(new UnsignedInteger64(String.valueOf(f.length())));
        attrs.setTimes(new UnsignedInteger32(f.lastModified() / 1000),
            new UnsignedInteger32(f.lastModified() / 1000));

        boolean canExec = true;

        try {
            if (System.getSecurityManager() != null) {
                System.getSecurityManager().checkExec(f.getCanonicalPath());
            }
        } catch (SecurityException ex1) {
            canExec = false;
        }

        attrs.setPermissions((((f.canRead() && permissions.canRead()) ? "r" : "-") +
            ((f.canWrite() && permissions.canWrite()) ? "w" : "-") +
            ((canExec && permissions.canExecute()) ? "x" : "-")));
        attrs.setPermissions(new UnsignedInteger32(attrs.getPermissions()
                                                        .longValue() |
                (f.isDirectory() ? FileAttributes.S_IFDIR : FileAttributes.S_IFREG)));

        return attrs;
    }
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.sftp.FileAttributes

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.