예제 #1
0
  private void doInternalArchive(
      File source, ZipArchiveOutputStream zos, String entryName, List<Throwable> throwables)
      throws IOException {
    if (source.isDirectory() && !source.isHidden()) {

      zos.putArchiveEntry(new ZipArchiveEntry(entryName + separator));

      for (File child : source.listFiles()) {
        doInternalArchive(child, zos, entryName + separator + child.getName(), throwables);
      }

    } else {

      if (source.isHidden()) {
        return;
      }

      InputStream in = null;

      try {

        ZipArchiveEntry entry = new ZipArchiveEntry(entryName);
        zos.putArchiveEntry(entry);

        in = new FileInputStream(source);
        IOs.piping(in, zos);
        zos.closeArchiveEntry();

      } catch (Exception e) {
        throwables.add(e);
      } finally {
        IOs.freeQuietly(in);
      }
    }
  }
예제 #2
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;
  }
예제 #3
0
 private void getAllSubFiles(File[] subFiles) {
   for (int i = 0; i < subFiles.length; i++) {
     File file = subFiles[i];
     if (!file.isHidden() && file.isDirectory()) {
       getAllSubFiles(file.listFiles());
     }
     if (!file.isHidden() && !file.isDirectory()) {
       filesToBeUploaded.put(file.getAbsolutePath().replaceAll(concatKey, ""), file);
     }
   }
 }
 protected int countFiles(File fileOrDir, Set<File> excluding) throws IOException {
   if (excluding.contains(fileOrDir)) return 0;
   int result = 0;
   if (fileOrDir.isDirectory() && !fileOrDir.isHidden()) {
     for (File child : fileOrDir.listFiles()) {
       result += countFiles(child, excluding);
     }
   } else if (fileOrDir.isFile() && !fileOrDir.isHidden()) {
     result++;
   }
   return result;
 }
예제 #5
0
 private void addFolder(File folder, ArrayList<File> filesInProgress) {
   if (!folder.canRead()) return;
   if (folder.isDirectory()) {
     for (File f : folder.listFiles()) {
       if (!f.canRead()) continue; // Ignore unreadable files
       if (f.isHidden() && !folder.isHidden())
         continue; // Do not dive into hidden dirs unless asked
       if (f.isDirectory()) addFolder(f, filesInProgress);
       else filesInProgress.add(f);
     }
   } else {
     filesInProgress.add(folder);
   }
 }
 /**
  * This method recursively process the directory folder
  *
  * @param dataDir directory of the data to be preprocessed
  * @throws java.lang.Exception
  */
 public void process(String dataDir) throws Exception {
   TextFilesFilter filter = new TextFilesFilter();
   File f = new File(dataDir);
   File[] listFiles = f.listFiles();
   for (File listFile : listFiles) {
     if (listFile.isDirectory()) {
       process(listFile.toString());
     } else {
       if (!listFile.isHidden()
           && listFile.exists()
           && listFile.canRead()
           && filter.accept(listFile)) {
         nbrDocs++;
         long start = System.currentTimeMillis();
         File unZippedFile = new File(listFile.getAbsolutePath().replaceFirst("[.][^.]+$", ""));
         unZipIt(listFile, unZippedFile);
         int total = parseFile(unZippedFile);
         long end = System.currentTimeMillis();
         long millis = (end - start);
         System.err.println(
             "A total of "
                 + total
                 + " lines were parsed from the file "
                 + listFile.getName()
                 + " in "
                 + Functions.getTimer(millis)
                 + ".");
         unZippedFile.delete();
       }
     }
   }
 }
예제 #7
0
  /*
   * @deprecated
   *
   * Search file of specific type in a directory
   * recursively and make sure reserved dirs be searched if provided This
   * method might be time-consuming, so you can use #relaySearchFilesOfType to
   * get search right after one level directory scanned.
   */
  public boolean searchFilesOfType(
      String topDir, int type, ArrayList<String> result, ArrayList<String> reservedSearchDirs) {
    ArrayList<String> typeList = null;
    switch (type) {
      case StorageUtil.TYPE_AUDIO:
        typeList = DataUtil.getSupportedAudioFileExtensions();
        break;
      case StorageUtil.TYPE_VIDEO:
        typeList = DataUtil.getSupportedVideoFileExtensions();
        break;
      case StorageUtil.TYPE_IMAGE:
        typeList = DataUtil.getSupportedImageFileExtensions();
        break;
      case StorageUtil.TYPE_APKFILE:
        typeList = DataUtil.getSupportedAppInstallerFileExtensions();
        break;
      default:
        // do nothing
        return false;
    }

    File root_dir = new File(topDir);
    String[] list = root_dir.list();

    if (list != null && root_dir.canRead()) {
      int len = list.length;

      for (int i = 0; i < len; i++) {
        File check = new File(topDir + "/" + list[i]);

        // skip symbol link and hidden files
        try {
          if (isSymlink(check) || check.isHidden()) {
            continue;
          }
        } catch (IOException e) {
          Log.e(TAG, "Failed to check symbol link!");
        }

        if (check.isFile()) {
          String extension = DataUtil.getFileExtensionWithoutDot(check.getPath());
          if (typeList.contains(extension.toLowerCase())) {
            result.add(check.getPath());
          }
        }
        if (check.isDirectory()) {
          if (StorageUtil.getExcludeSearchPath().contains(check.getAbsolutePath())
              || StorageUtil.isExcludeSearchPath(check.getAbsolutePath(), reservedSearchDirs)) {
            continue;
          } else {
            if (check.canRead() && !topDir.equals("/")) {
              searchFilesOfType(check.getAbsolutePath(), type, result, reservedSearchDirs);
            }
          }
        }
      }
    }

    return true;
  }
예제 #8
0
  /**
   * Delete files from the previous run of the database server.
   *
   * @param stem File stem
   */
  private static void deleteServerFiles() {
    final FilenameFilter serverFilesFilter =
        new FilenameFilter() {
          @Override
          public boolean accept(final File dir, final String name) {
            return Arrays.asList(
                    serverFileStem + ".lck",
                    serverFileStem + ".log",
                    serverFileStem + ".lobs",
                    serverFileStem + ".script",
                    serverFileStem + ".properties")
                .contains(name);
          }
        };

    final File[] files = new File(".").listFiles(serverFilesFilter);
    for (final File file : files) {
      if (!file.isDirectory() && !file.isHidden()) {
        final boolean delete = file.delete();
        if (!delete) {
          LOGGER.log(Level.FINE, "Could not delete " + file.getAbsolutePath());
        }
      }
    }
  }
예제 #9
0
  private List<String> getListOfSamplePagesForDoc(
      String documentType, String sampleBaseFolderPath) {

    List<String> listOfSamplePageTypes = new LinkedList<String>();
    StringBuffer sampleDocumentPath = new StringBuffer();
    sampleDocumentPath.append(sampleBaseFolderPath);
    sampleDocumentPath.append(File.separator);
    sampleDocumentPath.append(documentType);

    File fsampleDocumentPath = new File(sampleDocumentPath.toString());
    if (fsampleDocumentPath.exists() && fsampleDocumentPath.isDirectory()) {
      String[] arrOfSamplePageTypes;
      arrOfSamplePageTypes = fsampleDocumentPath.list();
      for (String samplePagetypeName : arrOfSamplePageTypes) {
        if (samplePagetypeName.equals(IImageMagickCommonConstants.THUMBS)) {
          continue;
        }
        File fSamplePagetypeName = new File(samplePagetypeName);
        if (fSamplePagetypeName.isHidden()) {
          continue;
        }
        listOfSamplePageTypes.add(samplePagetypeName);
      }

    } else {
      throw new DCMABusinessException(
          "Could not find the sample document folder=" + fsampleDocumentPath);
    }
    return listOfSamplePageTypes;
  }
예제 #10
0
 @Override
 public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) {
   Map<String, Object> result = new HashMap<String, Object>();
   String filePath = uri.toFileString();
   File file = new File(filePath);
   if (file.exists()) {
     Set<String> requestedAttributes = getRequestedAttributes(options);
     if (requestedAttributes == null
         || requestedAttributes.contains(IURIConverter.ATTRIBUTE_TIME_STAMP)) {
       result.put(IURIConverter.ATTRIBUTE_TIME_STAMP, file.lastModified());
     }
     if (requestedAttributes == null
         || requestedAttributes.contains(IURIConverter.ATTRIBUTE_LENGTH)) {
       result.put(IURIConverter.ATTRIBUTE_LENGTH, file.length());
     }
     if (requestedAttributes == null
         || requestedAttributes.contains(IURIConverter.ATTRIBUTE_READ_ONLY)) {
       result.put(IURIConverter.ATTRIBUTE_READ_ONLY, !file.canWrite());
     }
     if (requestedAttributes == null
         || requestedAttributes.contains(IURIConverter.ATTRIBUTE_HIDDEN)) {
       result.put(IURIConverter.ATTRIBUTE_HIDDEN, file.isHidden());
     }
     if (requestedAttributes == null
         || requestedAttributes.contains(IURIConverter.ATTRIBUTE_DIRECTORY)) {
       result.put(IURIConverter.ATTRIBUTE_DIRECTORY, file.isDirectory());
     }
   }
   return result;
 }
  public List<PluginWrapper> generatePluginWrappers() {
    List<PluginWrapper> mapList = new ArrayList<PluginWrapper>();
    File pluginWorkspaceDir = new File(pluginWorkspace);
    for (File file : pluginWorkspaceDir.listFiles()) {
      Map<String, String> map = new HashMap<String, String>();
      try {
        if (!file.isHidden()
            && !file.getName()
                .equals(
                    "tempCompressedPluginFileRepository")) { // avoid .svn dir and temp repository
          String configFilePath = file.getAbsolutePath() + "//config.conf";

          FileInputStream fileInpuStream = new FileInputStream(configFilePath);
          DataInputStream dataInputStream = new DataInputStream(fileInpuStream);
          BufferedReader bufferReader = new BufferedReader(new InputStreamReader(dataInputStream));
          String strLine;
          // Read File Line By Line
          while ((strLine = bufferReader.readLine()) != null) {
            addToMap(strLine, map);
          }
          // Close resource
          bufferReader.close();
          dataInputStream.close();
          fileInpuStream.close();
          PluginWrapper pluginWrapper = new PluginWrapper(file.getAbsolutePath(), map);
          mapList.add(pluginWrapper);
        }
      } catch (Exception e) { // Catch exception if any
        System.err.println("Error: " + e.getMessage());
      }
    }
    return mapList;
  }
예제 #12
0
파일: IsName.java 프로젝트: Horsmann/toobee
  private void init() throws TextClassificationException {
    if (namelist != null) {
      return;
    }
    namelist = new HashSet<String>();

    for (File file : folder.listFiles()) {
      if (file.isHidden()) {
        continue;
      }
      if (file.isDirectory()) {
        throw new TextClassificationException(
            "Did not expect that namelists are stored in subfolders");
      }

      List<String> readLines = null;
      try {
        readLines = FileUtils.readLines(file, "utf-8");
      } catch (IOException e) {
        throw new TextClassificationException(e);
      }
      for (String l : readLines) {
        if (l.startsWith("#")) {
          continue;
        }
        if (lowerCase) {
          l = l.toLowerCase();
        }

        namelist.add(l);
      }
    }
  }
  public void load() {
    datasources.clear();
    try {
      if (repoURL != null) {
        File[] files = new File(repoURL.getFile()).listFiles();

        for (File file : files) {
          if (!file.isHidden()) {
            Properties props = new Properties();
            props.load(new FileInputStream(file));
            String name = props.getProperty("name");
            String type = props.getProperty("type");
            if (name != null && type != null) {
              Type t = SaikuDatasource.Type.valueOf(type.toUpperCase());
              SaikuDatasource ds = new SaikuDatasource(name, t, props);
              datasources.put(name, ds);
            }
          }
        }
      } else {
        throw new Exception("repo URL is null");
      }
    } catch (Exception e) {
      throw new SaikuServiceException(e.getMessage(), e);
    }
  }
 private static void sendListing(ChannelHandlerContext ctx, File dir) {
   FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK);
   response.headers().set(CONTENT_TYPE, "text/html; charset=UTF-8");
   StringBuilder buf = new StringBuilder();
   String dirPath = dir.getPath();
   buf.append("<!DOCTYPE html>\r\n");
   buf.append("<html><head><title>");
   buf.append(dirPath);
   buf.append(" 目录:");
   buf.append("</title></head><body>\r\n");
   buf.append("<h3>");
   buf.append(dirPath).append(" 目录:");
   buf.append("</h3>\r\n");
   buf.append("<ul>");
   buf.append("<li>链接:<a href=\"../\">..</a></li>\r\n");
   for (File f : dir.listFiles()) {
     if (f.isHidden() || !f.canRead()) {
       continue;
     }
     String name = f.getName();
     if (!ALLOWED_FILE_NAME.matcher(name).matches()) {
       continue;
     }
     buf.append("<li>链接:<a href=\"");
     buf.append(name);
     buf.append("\">");
     buf.append(name);
     buf.append("</a></li>\r\n");
   }
   buf.append("</ul></body></html>\r\n");
   ByteBuf buffer = Unpooled.copiedBuffer(buf, CharsetUtil.UTF_8);
   response.content().writeBytes(buffer);
   buffer.release();
   ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
 }
예제 #15
0
  public void trainWhole(File dir) {
    File[] genreFolders = dir.listFiles(); // Array of genre folders.

    if (dir.exists()) System.out.println("The directory exists.");
    else System.out.println("The directory does not exist.");

    genres = new String[genreFolders.length]; // Array of genres as strings.
    mms = new MarkovModel[genreFolders.length]; // Array of Markov Models for each genre.

    System.out.println("There are " + genreFolders.length + " folders.");

    for (int i = 0; i < genreFolders.length; ++i) // For each folder...
    {
      if (!genreFolders[i].isHidden()) {
        genres[i] = genreFolders[i].getName(); // Set the new genre name.
        mms[i] = new MarkovModel(); // Initialize new MM.
        for (File file : genreFolders[i].listFiles()) // For each file in the genre folder...
        {
          if (!file.isHidden()) {
            mms[i].updateWhole(file); // Initial pass to update words and counts.
            mms[i].trainWhole(file); // Train it.
          }
        }
      }
    }
  }
 @Override
 public List<File> loadInBackground() {
   if (path == null || !path.isDirectory()) return Collections.emptyList();
   final File[] listed_files = path.listFiles();
   if (listed_files == null) return Collections.emptyList();
   final List<File> dirs = new ArrayList<File>();
   final List<File> files = new ArrayList<File>();
   for (final File file : listed_files) {
     if (!file.canRead() || file.isHidden()) {
       continue;
     }
     if (file.isDirectory()) {
       dirs.add(file);
     } else if (file.isFile()) {
       final String name = file.getName();
       final int idx = name.lastIndexOf(".");
       if (extensions == null
           || extensions.length == 0
           || idx == -1
           || idx > -1 && extensions_regex.matcher(name.substring(idx + 1)).matches()) {
         files.add(file);
       }
     }
   }
   Collections.sort(dirs, NAME_COMPARATOR);
   Collections.sort(files, NAME_COMPARATOR);
   final List<File> list = new ArrayList<File>();
   final File parent = path.getParentFile();
   if (path.getParentFile() != null) {
     list.add(parent);
   }
   list.addAll(dirs);
   list.addAll(files);
   return list;
 }
예제 #17
0
 /**
  * Function that checks if given file is being searched Returners true if current file has a right
  * type and wasn't used more than _numOfMonth
  *
  * @param file - file to check.
  * @return true if given file fits users criteria for search
  */
 private boolean isFileSearched(File file) {
   Path p = file.toPath();
   long cutoff = System.currentTimeMillis() - ((long) _numOfMonth * 30 * 24 * 60 * 60 * 1000);
   try {
     FileTime time = (FileTime) Files.getAttribute(p, "lastAccessTime", LinkOption.NOFOLLOW_LINKS);
     long lastAccessed = time.toMillis();
     if (lastAccessed <= cutoff && file.isHidden() == false) {
       if (_word)
         if (file.getName().endsWith(".doc")
             || file.getName().endsWith(".docx")
             || file.getName().endsWith(".DOC")
             || file.getName().endsWith(".DOCX")) return true;
       if (_exel)
         if (file.getName().endsWith(".xls")
             || file.getName().endsWith(".xlsx")
             || file.getName().endsWith(".XLS")
             || file.getName().endsWith(".XLSX")) return true;
       if (_pow)
         if (file.getName().endsWith(".ppt")
             || file.getName().endsWith(".pptx")
             || file.getName().endsWith(".PPT")
             || file.getName().endsWith(".PPTX")) return true;
       if (_pdf)
         if (file.getName().endsWith(".pdf") || file.getName().endsWith(".PDF")) return true;
     }
   } catch (IOException e) {
     return false;
   }
   return false;
 }
예제 #18
0
파일: JarFinder.java 프로젝트: imace/hops
 private static void zipDir(File dir, String relativePath, ZipOutputStream zos, boolean start)
     throws IOException {
   String[] dirList = dir.list();
   for (String aDirList : dirList) {
     File f = new File(dir, aDirList);
     if (!f.isHidden()) {
       if (f.isDirectory()) {
         if (!start) {
           ZipEntry dirEntry = new ZipEntry(relativePath + f.getName() + "/");
           zos.putNextEntry(dirEntry);
           zos.closeEntry();
         }
         String filePath = f.getPath();
         File file = new File(filePath);
         zipDir(file, relativePath + f.getName() + "/", zos, false);
       } else {
         String path = relativePath + f.getName();
         if (!path.equals(JarFile.MANIFEST_NAME)) {
           ZipEntry anEntry = new ZipEntry(path);
           InputStream is = new FileInputStream(f);
           copyToZipStream(is, anEntry, zos);
         }
       }
     }
   }
 }
  private void importFile(File file, IProject project, List<IBuildpathEntry> entries) {

    try {

      level++;

      // handle windows path separators
      String path = file.getAbsolutePath().replace("\\", "/").replace(symfonyPath, "");

      // import the directory
      if (file.isDirectory() && !file.isHidden()) {

        IFolder folder = project.getFolder(path);

        if (!folder.exists()) {
          folder.create(true, true, null);
        }

        // add root folders to buildpath
        if (level == 1 && !folder.getFullPath().toString().endsWith("bin")) {

          IPath[] exclusion = {};

          if (folder.getName().equals(SymfonyCoreConstants.APP_PATH)) {
            exclusion =
                new IPath[] {
                  new Path(SymfonyCoreConstants.CACHE_PATH), new Path(SymfonyCoreConstants.LOG_PATH)
                };
          } else if (folder.getName().equals(SymfonyCoreConstants.VENDOR_PATH)) {
            exclusion = new IPath[] {new Path(SymfonyCoreConstants.SKELETON_PATH)};
          }

          IBuildpathEntry entry = DLTKCore.newSourceEntry(folder.getFullPath(), exclusion);
          entries.add(entry);
        }

        // now import recursively
        for (File f : file.listFiles()) {
          importFile(f, project, entries);
        }

        // create the project file
      } else if (file.isFile() && ".gitkeep".equals(file.getName()) == false) {

        FileInputStream fis = new FileInputStream(file);
        IFile iFile = project.getFile(path);
        iFile.create(fis, true, null);
      }

      level--;

    } catch (CoreException e) {
      e.printStackTrace();
      Logger.logException(e);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      Logger.logException(e);
    }
  }
  private void getDir(String dirPath) {
    reports = new ArrayList<ReportData>();

    File f = new File(dirPath);
    File[] files = f.listFiles();

    // order files so most recent are nearest the top
    Arrays.sort(
        files,
        new Comparator<File>() {
          public int compare(File f1, File f2) {
            return Long.valueOf(f2.lastModified()).compareTo(f1.lastModified());
          }
        });

    for (int i = 0; i < files.length; i++) {
      File file = files[i];
      if (!file.isHidden()
          && !file.isDirectory()
          && db.getReportText(file.getAbsolutePath()) != null)
        reports.add(db.getReportDataFromThumb(file.getAbsolutePath()));
    }

    ReportDataAdapter adapter = new ReportDataAdapter(this, R.layout.row, reports);

    ListView listView = getListView();
    listView.setAdapter(adapter);

    listView.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(
              AdapterView<?> parent, View view, final int position, long id) {

            new AlertDialog.Builder(ReportHistoryActivity.this)
                .setTitle("Confirm Delete")
                .setMessage("Delete this report?")
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(
                    android.R.string.yes,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        DatabaseService db = new DatabaseService(getBaseContext());
                        db.deleteReport(reports.get(position).getImageUri().getPath());
                        Intent intent = new Intent();
                        intent.setClassName(
                            ServiceServer.getAndroidContext(),
                            "com.timetravellingtreasurechest.gui.ReportHistoryActivity");
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
                      }
                    })
                .setNegativeButton(android.R.string.no, null)
                .show();

            return true;
          }
        });
  }
예제 #21
0
 /**
  * Returns true if the pathname is 'hidden'. This method will always return false if the pathname
  * corresponds to a URL.
  *
  * @see java.io.File#isHidden()
  */
 public boolean isHidden() {
   if (isURL) {
     return false;
   }
   if (IS_WINDOWS) {
     return file.isHidden();
   }
   return file.getName().startsWith(".");
 }
 /**
  * File list update method.
  *
  * @param dir the directory
  */
 public void setDirectory(File dir) {
   if (dir.exists() && dir.isDirectory()) {
     File[] listFiles = dir.listFiles(filter);
     if (listFiles != null) {
       for (File file : listFiles) {
         if (!file.isHidden()) add(file);
       }
     }
   }
 }
예제 #23
0
 @Override
 public boolean accept(File f) {
   if (f.isHidden()) {
     if (f.isDirectory() && DemoRecorderUtils.getJustFileNameOfPath(f).equals(".nexuiz")) {
       return true;
     }
     return false; // don't show other hidden directories/files
   }
   return true;
 }
  /**
   * Retrieves the folder hierarchy for the specified folder (this method is NOT recursive and
   * doesn't go into the parent folder's subfolders.
   */
  private void getDir(String dirPath) {

    mDirectoryNamesList = Lists.newArrayList();
    mDirectoryPathsList = Lists.newArrayList();
    mDirectorySizesList = Lists.newArrayList();

    File f = new File(dirPath);
    File[] files = f.listFiles();
    Arrays.sort(files);

    if (files != null) {
      for (int i = 0; i < files.length; i++) {
        File file = files[i];
        if (!file.isHidden() && file.canRead()) {
          if (file.isDirectory()) {
            /* Starting with Android 4.2, /storage/emulated/legacy/...
             * is a symlink that points to the actual directory where
             * the user's files are stored. We need to detect the
             * actual directory's file path here.
             **/
            String filePath;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
              filePath = getRealFilePath(file.getAbsolutePath());
            else filePath = file.getAbsolutePath();

            mDirectoryPathsList.add(filePath);
            mDirectoryNamesList.add(file.getName());

            File[] listOfFiles = file.listFiles();

            if (listOfFiles != null) {
              mDirectorySizesList.add(
                  getResources()
                      .getQuantityString(
                          R.plurals.settings_cuc_local_dir_items,
                          listOfFiles.length,
                          listOfFiles.length));
            }
          }
        }
      }
    }

    boolean dirChecked = false;
    if (getLocalDirHashMap().get(dirPath) != null) dirChecked = getLocalDirHashMap().get(dirPath);

    LocalDirSelectionAdapter adapter =
        new LocalDirSelectionAdapter(getActivity(), this, dirChecked);

    mListView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

    mCurrentDir = dirPath;
    setCurrentDirText();
  }
 private void collectSubdirs(File file, Collection<File> subdirs) {
   subdirs.add(file);
   File[] files = file.listFiles();
   if (files != null) {
     for (File f : files) {
       if (f.isDirectory() & !f.isHidden()) {
         collectSubdirs(f, subdirs);
       }
     }
   }
 }
예제 #26
0
 private void reloadViews(final File directory) {
   directoryListBox.clearItems();
   fileListBox.clearItems();
   File[] entries = directory.listFiles();
   if (entries == null) {
     return;
   }
   Arrays.sort(
       entries,
       new Comparator<File>() {
         @Override
         public int compare(File o1, File o2) {
           return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
         }
       });
   directoryListBox.addItem(
       "..",
       new Runnable() {
         @Override
         public void run() {
           FileDialog.this.directory = directory.getAbsoluteFile().getParentFile();
           reloadViews(directory.getAbsoluteFile().getParentFile());
         }
       });
   for (final File entry : entries) {
     if (entry.isHidden() && !showHiddenFilesAndDirs) {
       continue;
     }
     if (entry.isDirectory()) {
       directoryListBox.addItem(
           entry.getName(),
           new Runnable() {
             @Override
             public void run() {
               FileDialog.this.directory = entry;
               reloadViews(entry);
             }
           });
     } else {
       fileListBox.addItem(
           entry.getName(),
           new Runnable() {
             @Override
             public void run() {
               fileBox.setText(entry.getName());
               setFocusedInteractable(okButton);
             }
           });
     }
   }
   if (fileListBox.isEmpty()) {
     fileListBox.addItem("<empty>", new DoNothing());
   }
 }
  /**
   * Gets (recursively) all the jbi.xml files under a given file.
   *
   * @param file the file to introspect (not included in the result)
   * @return the list of found jbi.xml files
   */
  private List<File> getAllJbiXmlFile(File file) {

    List<File> result = new ArrayList<File>();
    for (File f : file.listFiles()) {
      if (f.isFile() && f.getName().equals("jbi.xml")) result.add(f);
      else if (f.isDirectory() && (!f.isHidden() || f.getName().startsWith(".")))
        result.addAll(getAllJbiXmlFile(f));
    }

    return result;
  }
예제 #28
0
  public static void main(String[] args) throws IOException {
    File file =
        new File(
            "C:/Users/User/Desktop/Cradle Of Filth - Nymphetamine [OFFICIAL VIDEO] - YouTube.mp4");

    if (file.isHidden()) {
      System.out.println("This file is hidden");
    } else {
      System.out.println("This file is not hidden");
    }
  }
 @Override
 public boolean accept(File file) {
   try {
     return file != null
         && file.isDirectory()
         && !file.isHidden()
         && !DirScanner.isSymlink(file);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return false;
 }
예제 #30
0
  public static String[] getOfflineLayerList() {
    File[] files = new File(Collect.OFFLINE_LAYERS).listFiles();
    ArrayList<String> results = new ArrayList<String>();
    results.add(no_folder_key);
    for (File f : files) {
      if (f.isDirectory() && !f.isHidden()) {
        results.add(f.getName());
      }
    }

    return results.toArray(new String[0]);
  }