org.apache.commons.io.filefilter.FalseFileFilter Java Examples

The following examples show how to use org.apache.commons.io.filefilter.FalseFileFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PatternStats.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected void runSummary(File dir) throws FileNotFoundException, IOException, SAXException {
	HashMap<DittedBitSequence, PatternAccumulate> hashMap =
		new HashMap<>();

	Iterator<File> iterator = FileUtils.iterateFiles(dir,
		FileFilterUtils.prefixFileFilter("pat_"), FalseFileFilter.INSTANCE);

	while (iterator.hasNext()) {
		File f = iterator.next();
		accumulateFile(hashMap, new ResourceFile(f));
	}

	println("     Total FalseWith   FalseNo  Pattern");
	for (PatternAccumulate accum : hashMap.values()) {
		StringBuffer buf = new StringBuffer();
		accum.displaySummary(buf);
		println(buf.toString());
	}
}
 
Example #2
Source File: DirectoryModifiedStamper.java    From spoofax with Apache License 2.0 6 votes vote down vote up
@Override public Stamp stampOf(File directory) {
    if(!directory.exists()) {
        return new ValueStamp<>(this, -1L);
    } else if(!directory.isDirectory()) {
        throw new RuntimeException("Directory stamper cannot stamp " + directory + ", it is not a directory");
    } else if(filter != null && fileStamper != null) {
        final Map<File, Stamp> stamps = Maps.newHashMap();
        final Collection<File> files = FileUtils.listFiles(directory, filter, FalseFileFilter.INSTANCE);
        for(File file : files) {
            stamps.put(file, fileStamper.stampOf(file));
        }
        return new ValueStamp<>(this, stamps);
    } else {
        return new ValueStamp<>(this, directory.lastModified());
    }
}
 
Example #3
Source File: CopyPattern.java    From spoofax with Apache License 2.0 6 votes vote down vote up
@Override public None build(Input input) throws IOException {
    requireBuild(input.origin);

    require(input.srcDir, new DirectoryModifiedStamper());

    final Collection<File> files =
        FileUtils.listFiles(input.srcDir, new RegexFileFilter(input.pattern), FalseFileFilter.INSTANCE);
    for(File file : files) {
        require(file);
        final File dstFile = new File(input.dstDir, file.getName());
        FileUtils.copyFile(file, dstFile);
        provide(dstFile);
    }

    return None.val;
}
 
Example #4
Source File: JarDecompiler.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void processListing(File directory, TaskMonitor monitor) {

		// WARNING: this method starts a new thread for every directory found
		// in the extracted jar
		Iterator<File> iterator = FileUtils.iterateFilesAndDirs(directory, FalseFileFilter.INSTANCE,
			TrueFileFilter.INSTANCE);

		while (iterator.hasNext()) {
			File dir = iterator.next();
			Task task = new JarDecompilerTask(dir, jarFile.getName() + ":" + getRelPath(dir));
			TaskLauncher.launch(task);
		}
	}
 
Example #5
Source File: DumpStorageTask.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
	try {
		logger.print("schedule dump storage task start.");
		DumpStorage action = new DumpStorage();
		action.execute(Config.currentNode().dumpStorage().path());
		if (Config.currentNode().dumpStorage().size() > 0) {
			File dir = new File(Config.base(), "local/dump");
			List<File> list = new ArrayList<>();
			if (dir.exists() && dir.isDirectory()) {
				for (File f : FileUtils.listFilesAndDirs(dir, FalseFileFilter.FALSE, new RegexFileFilter(
						"^dumpStorage_[1,2][0,9][0-9][0-9][0,1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9]$"))) {
					if (dir != f) {
						list.add(f);
					}
				}
				list = list.stream().sorted(Comparator.comparing(File::getName).reversed())
						.collect(Collectors.toList());
				if (list.size() > Config.currentNode().dumpStorage().size()) {
					for (int i = Config.currentNode().dumpStorage().size(); i < list.size(); i++) {
						File file = list.get(i);
						logger.print("dumpStorageTask delete{}.", file.getAbsolutePath());
						FileUtils.forceDelete(file);
					}
				}
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #6
Source File: DumpDataTask.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	try {
		logger.print("schedule dump data task start.");
		DumpData action = new DumpData();
		action.execute(Config.currentNode().dumpData().path());
		if (Config.currentNode().dumpData().size() > 0) {
			File dir = new File(Config.base(), "local/dump");
			List<File> list = new ArrayList<>();
			if (dir.exists() && dir.isDirectory()) {
				for (File f : FileUtils.listFilesAndDirs(dir, FalseFileFilter.FALSE, new RegexFileFilter(
						"^dumpData_[1,2][0,9][0-9][0-9][0,1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9]$"))) {
					if (dir != f) {
						list.add(f);
					}
				}
				list = list.stream().sorted(Comparator.comparing(File::getName).reversed())
						.collect(Collectors.toList());
				if (list.size() > Config.currentNode().dumpData().size()) {
					for (int i = Config.currentNode().dumpData().size(); i < list.size(); i++) {
						File file = list.get(i);
						logger.print("dumpDataTask delete:{}.", file.getAbsolutePath());
						FileUtils.forceDelete(file);
					}
				}
			}
		}
	} catch (Exception e) {
		throw new JobExecutionException(e);
	}
}
 
Example #7
Source File: UpdateManager.java    From secrecy with Apache License 2.0 5 votes vote down vote up
void version32to53() {
    Collection folders = FileUtils.listFilesAndDirs(Storage.getRoot(), FalseFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    for (Object folderObject : folders) { //Search for dirs in root
        File folder = (File) folderObject;
        if (new File(folder, ".vault").exists() || !new File(folder, ".nomedia").exists()) {
            appendlog("\n" + folder.getAbsolutePath() + " is 5.x or not a vault, skip");
            continue; //The whole thing should be skipped because vault is in 5.x standard.
        }
        appendlog("\n" + folder.getAbsolutePath() + " is pre-5.x");
        Collection files = FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
        //walks the whole file tree, find out files that do not have encoded file names
        //and encode them.
        for (Object file : files) {
            File realFile = (File) file;
            if (".nomedia".equals(realFile.getName()))
                continue;
            String fileName = FilenameUtils.removeExtension(realFile.getName());
            fileName = fileName.replace("_thumb", "");
            try {
                Base64Coder.decodeString(fileName);
            } catch (IllegalArgumentException e) {
                String encodedFileName = Base64Coder.encodeString(fileName);
                fileName = realFile.getAbsolutePath().replace(fileName, encodedFileName);
                realFile.renameTo(new File(fileName));
            }
        }
    }
    version53to60();
}
 
Example #8
Source File: GoServer.java    From gocd with Apache License 2.0 5 votes vote down vote up
private List<File> getAddonJarFiles() {
    File addonsPath = new File(systemEnvironment.get(SystemEnvironment.ADDONS_PATH));
    if (!addonsPath.exists() || !addonsPath.canRead()) {
        return new ArrayList<>();
    }

    return new ArrayList<>(FileUtils.listFiles(addonsPath, new SuffixFileFilter("jar", IOCase.INSENSITIVE), FalseFileFilter.INSTANCE));
}
 
Example #9
Source File: AgentBootstrapper.java    From gocd with Apache License 2.0 4 votes vote down vote up
private void cleanupTempFiles() {
    FileUtils.deleteQuietly(new File(FileUtil.TMP_PARENT_DIR));
    FileUtils.deleteQuietly(new File("exploded_agent_launcher_dependencies")); // launchers extracted from old versions
    FileUtils.listFiles(new File("."), AGENT_LAUNCHER_TMP_FILE_FILTER, FalseFileFilter.INSTANCE).forEach(FileUtils::deleteQuietly);
    FileUtils.deleteQuietly(new File(new SystemEnvironment().getConfigDir(), "trust.jks"));
}
 
Example #10
Source File: FileUtils.java    From aion-germany with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns a filter that accepts directories in addition to the {@link File} objects accepted by the given filter.
 * 
 * @param dirFilter a base filter to add to
 * @return a filter that accepts directories 
 */
private static IOFileFilter setUpEffectiveDirFilter(IOFileFilter dirFilter) {
    return dirFilter == null ? FalseFileFilter.INSTANCE : FileFilterUtils.and(dirFilter,
            DirectoryFileFilter.INSTANCE);
}
 
Example #11
Source File: FileUtils.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a filter that accepts directories in addition to the {@link File} objects accepted by the given filter.
 *
 * @param dirFilter a base filter to add to
 * @return a filter that accepts directories
 */
private static IOFileFilter setUpEffectiveDirFilter(final IOFileFilter dirFilter) {
    return dirFilter == null ? FalseFileFilter.INSTANCE : FileFilterUtils.and(dirFilter,
            DirectoryFileFilter.INSTANCE);
}