Package com.sshtools.j2ssh.sftp

Examples of com.sshtools.j2ssh.sftp.FileAttributes


      dir = m_details.getSiteRoot()+dir;
     
      //  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
      FileAttributes attrib = m_sftp.stat(dir);
     
      String status = (attrib.isDirectory() == true) ? FileList.MSG_DEXIST : FileList.MSG_FEXIST;
      m_fileList.setStatus(m_count, status);
    }catch(IOException e){
      //  If the item doesnt exist, create a directory with the same name
      String status = FileList.MSG_OK;
      try{
View Full Code Here


         
          //  Ignores anything with a . or .. in it
          if(entry.getFilename().endsWith(".")) continue;

          //  Get the attributes for this directory item
          FileAttributes attrib = entry.getAttributes();
         
          //  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{
    System.out.println("TransferSSHTools::isDirectory(String dir)");
    try{
      //  Stat the requested site root
      FileAttributes attrib = m_sftp.stat(dir);
     
      //  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{
    System.out.println("TransferSSHTools::isFile(String file)");
    long size = -1;
    try{
      //  Stat the requested site root
      FileAttributes attrib = m_sftp.stat(file);
     
      //  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

      for(int a=0;a<tokens.length;a++){
        System.out.println("Token: "+tokens[a]);
        testDir+=tokens[a]+"/";
       
        try{
          FileAttributes attrib = m_sftp.stat(testDir);
         
          //  If these match, it's because this was the directory you TRIED to create
          //  You can't set the status of this if it was the parent directories, because you have
          //  to create the parent directories automatically for the user (because sometimes the site root doesnt exist)
          if(testDir == dir){
            status = (attrib.isDirectory() == true) ? FileList.MSG_DEXIST : FileList.MSG_FEXIST;
          }
        }catch(IOException ioe){
          //  If the item doesnt exist, create a directory with the same name
          status = FileList.MSG_OK;
          try{
View Full Code Here

         
          //  Ignores anything with a . or .. in it
          if(entry.getFilename().endsWith(".")) continue;

          //  Get the attributes for this directory item
          FileAttributes attrib = entry.getAttributes();
         
          //  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{
    System.out.println("TransferSSHTools::isDirectory(String dir)");
    try{
      //  Stat the requested site root
      FileAttributes attrib = m_sftp.stat(dir);
     
      //  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{
    System.out.println("TransferSSHTools::isFile(String file)");
    long size = -1;
    try{
      //  Stat the requested site root
      FileAttributes attrib = m_sftp.stat(file);
     
      //  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

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.