Esempio n. 1
0
  public static FileInfo getFileInfo(File f, FilenameFilter filter, boolean showHidden) {
    FileInfo lFileInfo = new FileInfo();
    String filePath = f.getPath();
    File lFile = new File(filePath);
    lFileInfo.canRead = lFile.canRead();
    lFileInfo.canWrite = lFile.canWrite();
    lFileInfo.isHidden = lFile.isHidden();
    lFileInfo.fileName = f.getName();
    lFileInfo.modifiedDate = lFile.lastModified();
    lFileInfo.isDir = lFile.isDirectory();
    lFileInfo.filePath = filePath;
    if (lFileInfo.isDir) {
      int lCount = 0;
      File[] files = lFile.listFiles(filter);

      // null means we cannot access this dir
      if (files == null) {
        return null;
      }

      for (File child : files) {
        if ((!child.isHidden() || showHidden) && isNormalFile(child.getAbsolutePath())) {
          lCount++;
        }
      }
      lFileInfo.count = lCount;

    } else {

      lFileInfo.fileSize = lFile.length();
    }
    return lFileInfo;
  }
Esempio n. 2
0
  public static FileInfo getFileInfo(File lFile) {

    FileInfo lFileInfo = new FileInfo();
    lFileInfo.canRead = lFile.canRead();
    lFileInfo.canWrite = lFile.canWrite();
    lFileInfo.isHidden = lFile.isHidden();
    lFileInfo.fileName = getNameFromFilepath(lFile.getAbsolutePath());
    lFileInfo.modifiedDate = lFile.lastModified();
    lFileInfo.isDir = lFile.isDirectory();
    lFileInfo.filePath = lFile.getAbsolutePath();
    lFileInfo.fileSize = lFile.length();
    return lFileInfo;
  }