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

The following examples show how to use org.apache.commons.io.filefilter.TrueFileFilter. 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: FileSynchronizer.java    From Hive2Hive with MIT License 6 votes vote down vote up
/**
 * Visit all files recursively and calculate the hash of the file. Folders are also added to the result.
 * 
 * @param root the root folder
 * @return a map where the key is the relative file path to the root and the value is the hash
 * @throws IOException if hashing fails
 */
public static Map<String, byte[]> visitFiles(File root) throws IOException {
	Map<String, byte[]> digest = new HashMap<String, byte[]>();
	Iterator<File> files = FileUtils.iterateFilesAndDirs(root, TrueFileFilter.TRUE, TrueFileFilter.TRUE);
	while (files.hasNext()) {
		File file = files.next();
		if (file.equals(root)) {
			// skip root folder
			continue;
		}
		String path = FileUtil.relativize(root, file).toString();
		byte[] hash = HashUtil.hash(file);
		if (file.isDirectory()) {
			digest.put(path + FileUtil.getFileSep(), hash);
		} else {
			digest.put(path, hash);
		}
	}
	return digest;
}
 
Example #2
Source File: DexToSmaliFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void getFileListing(File startingDirectory, GFileImpl currentRoot,
		TaskMonitor monitor) {

	Iterator<File> iterator = FileUtils.iterateFiles(startingDirectory, TrueFileFilter.INSTANCE,
		TrueFileFilter.INSTANCE);

	while (iterator.hasNext()) {
		File f = iterator.next();

		if (monitor.isCancelled()) {
			break;
		}
		monitor.setMessage(f.getName());

		GFileImpl gfile = GFileImpl.fromFilename(this, currentRoot, f.getName(),
			f.isDirectory(), f.length(), null);
		storeFile(gfile, f);
	}
}
 
Example #3
Source File: MixinResourcePackRepository.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author Mojang
 * @reason Fix a bug
 */
@Overwrite
private void deleteOldServerResourcesPacks() {
    try {
        List<File> lvt_1_1_ = Lists.newArrayList(FileUtils.listFiles(this.dirServerResourcepacks, TrueFileFilter.TRUE, null));
        Collections.sort(lvt_1_1_, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        int lvt_2_1_ = 0;
        Iterator lvt_3_1_ = lvt_1_1_.iterator();

        while(lvt_3_1_.hasNext()) {
            File lvt_4_1_ = (File) lvt_3_1_.next();
            if(lvt_2_1_++ >= 10) {
                logger.info("Deleting old server resource pack " + lvt_4_1_.getName());
                FileUtils.deleteQuietly(lvt_4_1_);
            }
        }
    }catch(final Throwable e) {
        e.printStackTrace();
    }
}
 
Example #4
Source File: MixinResourcePackRepository.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author Mojang
 * @reason Fix a bug
 */
@Overwrite
private void deleteOldServerResourcesPacks() {
    try {
        List<File> lvt_1_1_ = Lists.newArrayList(FileUtils.listFiles(this.dirServerResourcepacks, TrueFileFilter.TRUE, null));
        Collections.sort(lvt_1_1_, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        int lvt_2_1_ = 0;
        Iterator lvt_3_1_ = lvt_1_1_.iterator();

        while(lvt_3_1_.hasNext()) {
            File lvt_4_1_ = (File) lvt_3_1_.next();
            if(lvt_2_1_++ >= 10) {
                logger.info("Deleting old server resource pack " + lvt_4_1_.getName());
                FileUtils.deleteQuietly(lvt_4_1_);
            }
        }
    }catch(final Throwable e) {
        e.printStackTrace();
    }
}
 
Example #5
Source File: FileService.java    From Refactoring-Bot with MIT License 6 votes vote down vote up
/**
 * This method returns all Javafile-Paths of a project from a configuration.
 * 
 * @param repoFolderPath
 * @return allJavaFiles
 * @throws IOException
 */
public List<String> getAllJavaFiles(String repoFolderPath) throws IOException {
	// Init all java files path-list
	List<String> allJavaFiles = new ArrayList<>();

	// Get root folder of project
	File dir = new File(repoFolderPath);

	// Get paths to all java files of the project
	List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
	for (File file : files) {
		if (file.getCanonicalPath().endsWith(".java")) {
			allJavaFiles.add(file.getCanonicalPath());
		}
	}
	return allJavaFiles;
}
 
Example #6
Source File: DataBackupIntentService.java    From OmniList with GNU Affero General Public License v3.0 6 votes vote down vote up
private void importAttachments(File backupDir) {
    File attachmentsDir = FileHelper.getAttachmentDir(this);
    File backupAttachmentsDir = new File(backupDir, attachmentsDir.getName());
    if (!backupAttachmentsDir.exists()) {
        return;
    }
    Collection<File> list = FileUtils.listFiles(backupAttachmentsDir, FileFilterUtils.trueFileFilter(), TrueFileFilter.INSTANCE);
    int imported = 0, size = list.size();
    for (File file : list) {
        try {
            FileUtils.copyFileToDirectory(file, attachmentsDir, true);
            mNotificationsHelper.setMessage(getString(R.string.text_attachment) + " " + imported++ + "/" + size).show();
        } catch (IOException e) {
            LogUtils.e("Error importing the attachment " + file.getName());
        }
    }
}
 
Example #7
Source File: NativeSoUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Verify the directory of the so file under the abi
 *
 * @param supportAbis
 * @param removeSoFiles
 * @param dirs
 * @return
 */
public static Map<String, Multimap<String, File>> getAbiSoFiles(Set<String> supportAbis, Set<String> removeSoFiles,
                                                                List<File> dirs) {
    Map<String, Multimap<String, File>> result = new HashMap<String, Multimap<String, File>>();
    IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
    for (File dir : dirs) {
        Collection<File> files = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
        for (File file : files) {
            File parentFolder = file.getParentFile();
            String parentName = parentFolder.getName();
            String shortName = getSoShortName(file);
            Multimap<String, File> maps = result.get(parentName);
            if (null == maps) {
                maps = HashMultimap.create(10, 3);
            }
            maps.put(shortName, file);
            result.put(parentName, maps);
        }

    }
    return result;
}
 
Example #8
Source File: ApkFileListUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the file list information for the apk file
 *
 * @return
 */
protected static void prepareApkFileList(File folder, String prefixName, ApkFiles apkFiles) {
    if (!folder.exists()) {
        return;
    }
    // Gets information about the main bundle
    Collection<File> files = FileUtils.listFiles(folder, new PureFileFilter(), TrueFileFilter.INSTANCE);
    for (File file : files) {
        if (file.isFile()) {
            String relativePath = prefixName + File.separator + PathUtil.toRelative(folder, file.getAbsolutePath());
            String md5;
            if ("res".equals(prefixName)) {
                md5 = getResMd5(file);
            } else {
                md5 = MD5Util.getFileMD5(file);
            }
            if (isImageFile(relativePath)) {
                apkFiles.apkFileList.put(relativePath, md5);
            }
            apkFiles.finalApkFileList.put(relativePath, md5);
        }
    }
}
 
Example #9
Source File: ApkFileListUtils.java    From atlas with Apache License 2.0 6 votes vote down vote up
protected static void prepareApkFileList(File folder, String prefixName, String awbName, ApkFiles apkFiles) {
    if (!folder.exists()) {
        return;
    }
    // Gets information about the main bundle
    Collection<File> files = FileUtils.listFiles(folder, new PureFileFilter(), TrueFileFilter.INSTANCE);
    for (File file : files) {
        if (file.isFile()) {
            String relativePath = prefixName + File.separator + PathUtil.toRelative(folder, file.getAbsolutePath());
            String md5 = MD5Util.getFileMD5(file);
            if (isImageFile(relativePath)) {
                if (null == apkFiles.apkFileList.getAwbs().get(awbName)) {
                    apkFiles.apkFileList.getAwbs().put(awbName, new HashMap<String, String>());
                }
                apkFiles.apkFileList.getAwbs().get(awbName).put(relativePath, md5);
            }
            if (null == apkFiles.finalApkFileList.getAwbs().get(awbName)) {
                apkFiles.finalApkFileList.getAwbs().put(awbName, new HashMap<String, String>());
            }
            apkFiles.finalApkFileList.getAwbs().get(awbName).put(relativePath, md5);
        }
    }

}
 
Example #10
Source File: FilesController.java    From AudioBookConverter with GNU General Public License v2.0 6 votes vote down vote up
private List<String> collectFiles(Collection<File> files) {
    List<String> fileNames = new ArrayList<>();
    ImmutableSet<String> extensions = ImmutableSet.copyOf(FILE_EXTENSIONS);

    for (File file : files) {
        if (file.isDirectory()) {
            SuffixFileFilter suffixFileFilter = new SuffixFileFilter(toSuffixes(".", FILE_EXTENSIONS), IOCase.INSENSITIVE);
            Collection<File> nestedFiles = FileUtils.listFiles(file, suffixFileFilter, TrueFileFilter.INSTANCE);
            nestedFiles.stream().map(File::getPath).forEach(fileNames::add);
        } else {
            boolean allowedFileExtension = extensions.contains(FilenameUtils.getExtension(file.getName()).toLowerCase());
            if (allowedFileExtension) {
                fileNames.add(file.getPath());
            }
        }
    }
    return fileNames;
}
 
Example #11
Source File: JavaTestCompilerMojo.java    From wisdom with Apache License 2.0 6 votes vote down vote up
/**
 * A new (accepted) file was deleted. This methods triggers the Java compilation.
 *
 * @param file the file
 * @return {@literal true}
 * @throws org.wisdom.maven.WatchingException thrown on compilation error. The thrown exception contains the file, line,
 *                           character and reason of the compilation error.
 */
@Override
public boolean fileDeleted(final File file) throws WatchingException {
    // Delete the associated class file.
    // We delete more than required... but the inner class case is very tricky.
    Collection<File> files = FileUtils.listFiles(classes, new IOFileFilter() {
        @Override
        public boolean accept(File test) {
            String classname = FilenameUtils.getBaseName(test.getName());
            String filename = FilenameUtils.getBaseName(file.getName());
            return classname.equals(filename) || classname.startsWith(filename + "$");
        }

        @Override
        public boolean accept(File dir, String name) {
            return accept(new File(dir, name));
        }
    }, TrueFileFilter.INSTANCE);

    for (File clazz : files) {
        getLog().debug("Deleting " + clazz.getAbsolutePath() + " : " + clazz.delete());
    }

    compile();
    return true;
}
 
Example #12
Source File: ProjectImpl.java    From japi with MIT License 6 votes vote down vote up
@Override
public List<IPackage> getPackages() {
    String masterProjectActionPath = JapiClient.getConfig().getPrefixPath() + JapiClient.getConfig().getProjectJavaPath() + JapiClient.getConfig().getPostfixPath() + "/" + JapiClient.getConfig().getActionReletivePath();
    File actionFold = new File(masterProjectActionPath);
    if (!actionFold.exists()) {
        throw new JapiException(masterProjectActionPath + " fold not exists.");
    }
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory();
        }
    });
    Collection<File> folds = FileUtils.listFilesAndDirs(actionFold, dirFilter, TrueFileFilter.INSTANCE);
    List<IPackage> packages = new ArrayList<>(folds.size());
    for (File fold : folds) {
        if (!fold.getAbsolutePath().equals(actionFold.getAbsolutePath())) {
            PackageImpl packageImpl = new PackageImpl();
            packageImpl.setPackageFold(fold);
            packages.add(packageImpl);
        }
    }
    return packages;
}
 
Example #13
Source File: PatchFileBuilder.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * 将指定文件夹下的文件转换为map
 *
 * @param folder
 * @return
 * @throws PatchException
 */
private Map<String, FileDef> getListFileMap(File folder) throws PatchException, IOException {
    Map<String, FileDef> map = new HashMap<String, FileDef>();
    if (!folder.exists() || !folder.isDirectory()) {
        throw new PatchException("The input folder:" + folder.getAbsolutePath()
                + " does not existed or is not a directory!");
    }
    Collection<File> files = FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    for (File file : files) {
        String path = PathUtils.toRelative(folder, file.getAbsolutePath());
        String md5 = MD5Util.getFileMD5String(file);
        FileDef fileDef = new FileDef(md5, path, file);
        map.put(path, fileDef);
    }
    return map;
}
 
Example #14
Source File: FileDAO.java    From MtgDesktopCompanion with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<MagicCardStock> listStocks(MagicCard mc, MagicCollection col,boolean editionStrict) throws SQLException {
	List<MagicCardStock> st = new ArrayList<>();
	File f = new File(directory, STOCKDIR);
	for (File fstock : FileUtils.listFiles(f, new WildcardFileFilter("*" + IDGenerator.generate(mc)),TrueFileFilter.INSTANCE)) {
		try {
			MagicCardStock s = read(MagicCardStock.class, fstock);
			if (s.getMagicCollection().getName().equals(col.getName()))
				st.add(s);

		} catch (Exception e) {
			throw new SQLException(e);
		}
	}

	return st;
}
 
Example #15
Source File: DirectoryMonitor.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
public DirectoryMonitor(String directorypath, long polling, String classname) {

        this.directory = new File(directorypath);
        this.trackedClassName = classname;
        this.polling = polling;

        if (!directory.isDirectory()) {
            LOG.info("Monitored directory {} not existing - creating directory", directory.getAbsolutePath());
            if (!this.directory.mkdirs()) {
                throw new IllegalStateException("Monitored directory doesn't exist and cannot be created.");
            }
        }

        // We observes all files.
        FileAlterationObserver observer = new FileAlterationObserver(directory, TrueFileFilter.INSTANCE);
        observer.checkAndNotify();
        observer.addListener(new FileMonitor());
        monitor = new FileAlterationMonitor(polling, observer);

    }
 
Example #16
Source File: JobDetailPresentationModel.java    From gocd with Apache License 2.0 6 votes vote down vote up
public String getIndexPageURL()  {
    try {
        File testOutputFolder = artifactsService.findArtifact(job.getIdentifier(), TEST_OUTPUT_FOLDER);

        if (testOutputFolder.exists()) {
            Collection<File> files = FileUtils.listFiles(testOutputFolder, new NameFileFilter("index.html"), TrueFileFilter.TRUE);
            if (files.isEmpty()) {
                return null;
            }
            File testIndexPage = files.iterator().next();
            return getRestfulUrl(testIndexPage.getPath().substring(testIndexPage.getPath().indexOf(TEST_OUTPUT_FOLDER)));
        }
    } catch (Exception ignore) {

    }
    return null;
}
 
Example #17
Source File: Files.java    From writelatex-git-bridge with MIT License 6 votes vote down vote up
private static Set<Path> getChildren(File f0, Path f0Base) {
    return FileUtils.listFilesAndDirs(
            f0,
            TrueFileFilter.TRUE,
            TrueFileFilter.TRUE
    ).stream(
    ).map(
            File::getAbsolutePath
    ).map(
            Paths::get
    ).map(p ->
            f0Base.relativize(p)
    ).filter(p ->
            !p.toString().isEmpty()
    ).collect(
            Collectors.toSet()
    );
}
 
Example #18
Source File: PartFilesReassembly.java    From p3-batchrefine with Apache License 2.0 5 votes vote down vote up
public static void reconstructLineBased(File partFolder,
		File reconstructed, boolean removeHeaders) throws IOException {
	Path tmpOut = Files.createTempFile(partFolder.toPath(), "reconstr",
			".tmp");
	BufferedOutputStream dstOut = new BufferedOutputStream(
			new FileOutputStream(tmpOut.toFile()));
	try {
		if (!Files.isDirectory(partFolder.toPath()))
			throw new IOException("Not a directory: " + partFolder);
		File[] fileList = FileUtils.listFiles(partFolder,
				new PrefixFileFilter("part"), TrueFileFilter.TRUE).toArray(
				new File[0]);
		Arrays.sort(fileList);

		for (int i = 0; i < fileList.length; i++) {
			if (fileList[i].canRead()) {
				BufferedReader in = new BufferedReader(new FileReader(
						fileList[i]));
				try {
					if (removeHeaders && i != 0)
						in.readLine();
					IOUtils.copy(in, dstOut);

				} finally {
					in.close();
				}
			}
		}
	} finally {
		dstOut.close();
	}

	Files.move(tmpOut, reconstructed.toPath(),
			StandardCopyOption.ATOMIC_MOVE,
			StandardCopyOption.REPLACE_EXISTING);
	FileUtils.deleteQuietly(tmpOut.toFile());
	FileUtils.deleteQuietly(partFolder);
}
 
Example #19
Source File: CanalAdminController.java    From canal with Apache License 2.0 5 votes vote down vote up
@Override
public String listInstanceLog(String destination) {
    Collection<File> files = org.apache.commons.io.FileUtils.listFiles(new File("../logs/" + destination + "/"),
        TrueFileFilter.TRUE,
        TrueFileFilter.TRUE);
    List<String> names = files.stream().map(f -> f.getName()).collect(Collectors.toList());
    return Joiner.on(",").join(names);
}
 
Example #20
Source File: PartFilesReassembly.java    From p3-batchrefine with Apache License 2.0 5 votes vote down vote up
/**
 * Method that to reconstruct part* files into a single file <BR>
 * Suitable for line-based, CSV files.
 * 
 * @param partFolder
 *            directory contatining partial files (part001,part002..)
 * @param reconstructed
 *            file to which the output is written
 * @throws IOException
 */

public static void reconstructLineBased(File partFolder,
		File reconstructed, boolean removeHeaders) throws IOException {
	Path tmpOut = Files.createTempFile(partFolder.toPath(), "reconstr",
			".tmp");
	BufferedOutputStream dstOut = new BufferedOutputStream(
			new FileOutputStream(tmpOut.toFile()));
	try {
		if (!Files.isDirectory(partFolder.toPath()))
			throw new IOException("Not a directory: " + partFolder);
		File[] fileList = FileUtils.listFiles(partFolder,
				new PrefixFileFilter("part"), TrueFileFilter.TRUE).toArray(
				new File[0]);
		Arrays.sort(fileList);

		for (int i = 0; i < fileList.length; i++) {
			if (fileList[i].canRead()) {
				BufferedReader in = new BufferedReader(new FileReader(
						fileList[i]));
				try {
					if (removeHeaders && i != 0)
						in.readLine();
					IOUtils.copy(in, dstOut);

				} finally {
					in.close();
				}
			}
		}
	} finally {
		dstOut.close();
	}

	Files.move(tmpOut, reconstructed.toPath(),
			StandardCopyOption.ATOMIC_MOVE,
			StandardCopyOption.REPLACE_EXISTING);
	FileUtils.deleteQuietly(tmpOut.toFile());
	FileUtils.deleteQuietly(partFolder);
}
 
Example #21
Source File: CachedRemoteFileSystem.java    From imhotep with Apache License 2.0 5 votes vote down vote up
private void scanExistingFiles() throws IOException {
    final Iterator<File> filesInCache;
    final int prefixLen;
    
    prefixLen = localCacheDir.getCanonicalPath().length() + DELIMITER.length();
    filesInCache = FileUtils.iterateFiles(localCacheDir, 
                                          TrueFileFilter.INSTANCE, 
                                          TrueFileFilter.INSTANCE);
    while (filesInCache.hasNext()) {
        final File cachedFile = filesInCache.next();
        final String path = cachedFile.getCanonicalPath();
        String cachePath = path.substring(prefixLen);
        cache.put(cachePath, cachedFile);
    }
}
 
Example #22
Source File: FileDAO.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<MagicCollection> listCollectionFromCards(MagicCard mc) throws SQLException {

	String id = IDGenerator.generate(mc);
	File f = new File(directory, CARDSDIR);
	List<MagicCollection> ret = new ArrayList<>();
	Collection<File> res = FileUtils.listFiles(f, new NameFileFilter(id), TrueFileFilter.INSTANCE);

	for (File result : res)
		ret.add(new MagicCollection(result.getParentFile().getParentFile().getName()));

	return ret;
}
 
Example #23
Source File: JPAPersistenceUnitPostProcessor.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Search for <code>WEB-INF/conf/plugins/*.orm.xml</code>.
 * 
 * @return list of files found
 */
private Collection<File> getListORMFiles( )
{
    String strConfPath = AppPathService.getAbsolutePathFromRelativePath( PATH_CONF );
    File dirConfPlugins = new File( strConfPath );

    return FileUtils.listFiles( dirConfPlugins, FileFilterUtils.suffixFileFilter( SUFFIX_ORM_XML ), TrueFileFilter.INSTANCE );
}
 
Example #24
Source File: DownloaderController.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * Logs all files found in the specified local directory.
 *
 * @param directory the target local directory
 */
private void logLocalDirectoryContents(File directory)
{
    Collection<File> files = HerdFileUtils.listFiles(directory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    LOGGER.info(String.format("Found %d files in \"%s\" target local directory:", files.size(), directory.getPath()));

    for (File file : files)
    {
        LOGGER.info(String.format("    %s", file.getPath()));
    }
}
 
Example #25
Source File: ProtocJarMojo.java    From protoc-jar-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void processTarget(OutputTarget target) throws MojoExecutionException {
	boolean shaded = false;
	String targetType = target.type;
	if (targetType.equals("java-shaded") || targetType.equals("java_shaded")) {
		targetType = "java";
		shaded = true;
	}
	
	FileFilter fileFilter = new FileFilter(extension);
	for (File input : inputDirectories) {
		if (input == null) continue;
		
		if (input.exists() && input.isDirectory()) {
			Collection<File> protoFiles = FileUtils.listFiles(input, fileFilter, TrueFileFilter.INSTANCE);
			for (File protoFile : protoFiles) {
				if (target.cleanOutputFolder || buildContext.hasDelta(protoFile.getPath())) {
					processFile(protoFile, protocVersion, targetType, target.pluginPath, target.outputDirectory, target.outputOptions);
				}
				else {
					getLog().info("Not changed " + protoFile);
				}
			}
		}
		else {
			if (input.exists()) getLog().warn(input + " is not a directory");
			else getLog().warn(input + " does not exist");
		}
	}
	
	if (shaded) {
		try {
			getLog().info("    Shading (version " + protocVersion + "): " + target.outputDirectory);
			Protoc.doShading(target.outputDirectory, protocVersion);
		}
		catch (IOException e) {
			throw new MojoExecutionException("Error occurred during shading", e);
		}
	}		
}
 
Example #26
Source File: LibraryFileSetManager.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public Set<String> updateFrom(IProject project) {
 	Lock writeLock = readWriteLock.writeLock();
 	writeLock.lock();
 	try{
 		remove(project.getName());
  	XdsProjectSettings xdsProjectSettings = XdsProjectSettingsManager.getXdsProjectSettings(project);
  	final Set<String> absolutePathes = new HashSet<String>();
  	Sdk sdk = xdsProjectSettings.getProjectSdk();
  	if (sdk == null) {
  		return absolutePathes;
  	}
String sdkLibraryDir = sdk.getLibraryDefinitionsPath();
  	if (StringUtils.isBlank(sdkLibraryDir) || !new File(sdkLibraryDir).exists()) {
  		return absolutePathes;
  	}
  	Iterator<File> files = FileUtils.iterateFiles(new File(sdkLibraryDir), DefinitionFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
  	for (; files.hasNext();) {
  		File file = files.next();
  		absolutePathes.add(ResourceUtils.getAbsolutePathAsInFS(file.getAbsolutePath()));
}
  	add(project.getName(), absolutePathes);
  	return Collections.unmodifiableSet(absolutePathes);
 	}
 	finally{
 		writeLock.unlock();
 	}
 }
 
Example #27
Source File: DirectoryMatcher.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean matchesSafely(File directory) {
    return directory.isDirectory() && !FileUtils.listFiles(
            directory,
            new NameFileFilter(fileName),
            TrueFileFilter.INSTANCE
    ).isEmpty();
}
 
Example #28
Source File: BuildImageCmdIT.java    From docker-java with Apache License 2.0 5 votes vote down vote up
@Test
public void buildImageFromTar() throws Exception {
    File baseDir = fileFromBuildTestResource("ADD/file");
    Collection<File> files = FileUtils.listFiles(baseDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    File tarFile = CompressArchiveUtil.archiveTARFiles(baseDir, files, UUID.randomUUID().toString());
    String response = dockerfileBuild(new FileInputStream(tarFile));
    assertThat(response, containsString("Successfully executed testrun.sh"));
}
 
Example #29
Source File: AbstractGoDependencyAwareMojo.java    From mvn-golang with Apache License 2.0 5 votes vote down vote up
private void restoreGoModFromBackupAndRemoveBackup(@Nonnull final File folder) throws IOException {
  final Collection<File> backupFiles = FileUtils.listFiles(folder, FileFilterUtils.nameFileFilter(GO_MOD_FILE_NAME_BAK), TrueFileFilter.INSTANCE);

  this.getLog().debug(String.format("Restoring go.mod from backup in %s, detected %d files", folder, backupFiles.size()));

  for (final File backup : backupFiles) {
    final File restored = new File(folder, GO_MOD_FILE_NAME);
    if (restored.isFile() && !restored.delete()) {
      throw new IOException("Can't delete file during backup restore: " + restored);
    }
    if (!backup.renameTo(restored)) {
      throw new IOException("Can't rename backup: " + backup + " -> " + restored);
    }
  }
}
 
Example #30
Source File: GenerateDocumentation.java    From webanno with Apache License 2.0 5 votes vote down vote up
public static void main(String... args) throws Exception
{
    Path webannoDir = getWebannoDir();
    Path outputDir = Paths.get(System.getProperty("user.dir")).resolve("target")
            .resolve("doc-out");

    List<Path> modules = new ArrayList<>();
    modules.addAll(getAsciiDocs(webannoDir));

    FileUtils.deleteQuietly(outputDir.toFile());
    Files.createDirectory(outputDir);

    for (Path module : modules) {
        System.out.printf("Including module: %s\n", module);
        
        for (File f : FileUtils.listFiles(module.toFile(), TrueFileFilter.INSTANCE,
                TrueFileFilter.INSTANCE)) {
            Path p = f.toPath();
            Path targetPath = f.toPath().subpath(module.toAbsolutePath().getNameCount()
                    , p.toAbsolutePath().getNameCount());
            FileUtils.copyFile(f, outputDir.resolve("asciidoc").resolve(targetPath).toFile());
        }
    }

    buildDoc("user-guide", outputDir);
    buildDoc("developer-guide", outputDir);
    buildDoc("admin-guide", outputDir);
    
    System.out.printf("Documentation written to: %s\n", outputDir);
}