Search in sources :

Example 21 with IOFileFilter

use of org.apache.commons.io.filefilter.IOFileFilter in project pcgen by PCGen.

the class ExportDialog method refreshFiles.

private void refreshFiles() {
    if (allTemplates != null) {
        String outputSheetsDir;
        SheetFilter sheetFilter = (SheetFilter) exportBox.getSelectedItem();
        IOFileFilter ioFilter = FileFilterUtils.asFileFilter(sheetFilter);
        IOFileFilter prefixFilter;
        String defaultSheet = null;
        String outputSheetDirectory = SettingsHandler.getGame().getOutputSheetDirectory();
        if (outputSheetDirectory == null) {
            outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + sheetFilter.getPath();
        } else {
            outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + outputSheetDirectory + "/" + sheetFilter.getPath();
        }
        if (partyBox.isSelected()) {
            prefixFilter = FileFilterUtils.prefixFileFilter(Constants.PARTY_TEMPLATE_PREFIX);
        } else {
            CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem();
            prefixFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX);
            defaultSheet = character.getDefaultOutputSheet(sheetFilter == SheetFilter.PDF);
            if (StringUtils.isEmpty(defaultSheet)) {
                defaultSheet = outputSheetsDir + "/" + SettingsHandler.getGame().getOutputSheetDefault(sheetFilter.getTag());
            }
        }
        IOFileFilter filter = FileFilterUtils.and(prefixFilter, ioFilter);
        List<File> files = FileFilterUtils.filterList(filter, allTemplates);
        Collections.sort(files);
        URI osPath = new File(outputSheetsDir).toURI();
        Object[] uriList = new Object[files.size()];
        for (int i = 0; i < uriList.length; i++) {
            uriList[i] = osPath.relativize(files.get(i).toURI());
        }
        fileList.setListData(uriList);
        if (StringUtils.isNotEmpty(defaultSheet)) {
            URI defaultPath = new File(defaultSheet).toURI();
            fileList.setSelectedValue(osPath.relativize(defaultPath), true);
        }
    }
}
Also used : IOFileFilter(org.apache.commons.io.filefilter.IOFileFilter) CharacterFacade(pcgen.facade.core.CharacterFacade) File(java.io.File) URI(java.net.URI)

Example 22 with IOFileFilter

use of org.apache.commons.io.filefilter.IOFileFilter in project ignite by apache.

the class CacheGroupMetricsWithIndexTest method testIndexRebuildCountPartitionsLeftInCluster.

/**
 * Test number of partitions need to finished indexes rebuilding.
 * <p>Case:
 * <ul>
 *     <li>Start cluster, load data with indexes</li>
 *     <li>Kill single node, delete index.bin, start node.</li>
 *     <li>Make sure that index rebuild count is in range of total new index size and 0 and decreasing</li>
 *     <li>Wait until rebuild finished, assert that no index errors</li>
 * </ul>
 * </p>
 */
@Test
public void testIndexRebuildCountPartitionsLeftInCluster() throws Exception {
    pds = true;
    Ignite ignite = startGrid(0);
    startGrid(1);
    ignite.cluster().active(true);
    IgniteCache<Object, Object> cache1 = ignite.cache(CACHE_NAME);
    for (int i = 0; i < 100_000; i++) {
        Long id = (long) i;
        BinaryObjectBuilder o = ignite.binary().builder(OBJECT_NAME).setField(KEY_NAME, id).setField(COLUMN1_NAME, i / 2).setField(COLUMN2_NAME, "str" + Integer.toHexString(i));
        cache1.put(id, o.build());
    }
    String consistentId = ignite.cluster().localNode().consistentId().toString();
    stopGrid(0);
    File dir = U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR, false);
    IOFileFilter filter = FileFilterUtils.nameFileFilter("index.bin");
    Collection<File> idxBinFiles = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
    for (File indexBin : idxBinFiles) if (indexBin.getAbsolutePath().contains(consistentId))
        U.delete(indexBin);
    startGrid(0);
    MetricRegistry metrics = cacheGroupMetrics(0, GROUP_NAME).get2();
    LongMetric idxBuildCntPartitionsLeft = metrics.findMetric("IndexBuildCountPartitionsLeft");
    assertTrue("Timeout wait start rebuild index", waitForCondition(() -> idxBuildCntPartitionsLeft.value() > 0, 30_000));
    assertTrue("Timeout wait finished rebuild index", GridTestUtils.waitForCondition(() -> idxBuildCntPartitionsLeft.value() == 0, 30_000));
}
Also used : MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) IOFileFilter(org.apache.commons.io.filefilter.IOFileFilter) Ignite(org.apache.ignite.Ignite) LongMetric(org.apache.ignite.spi.metric.LongMetric) BinaryObjectBuilder(org.apache.ignite.binary.BinaryObjectBuilder) File(java.io.File) Test(org.junit.Test)

Example 23 with IOFileFilter

use of org.apache.commons.io.filefilter.IOFileFilter in project project-build-plugin by axonivy.

the class FileLogForwarder method activate.

public synchronized void activate() throws MojoExecutionException {
    IOFileFilter logFilter = FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.nameFileFilter(engineLog.getName()));
    FileAlterationObserver fileObserver = new FileAlterationObserver(engineLog.getParent(), logFilter);
    fileObserver.addListener(new LogModificationListener());
    monitor = new FileAlterationMonitor(100);
    monitor.addObserver(fileObserver);
    try {
        monitor.start();
    } catch (Exception ex) {
        throw new MojoExecutionException("Failed to activate deploy log forwarder", ex);
    }
}
Also used : FileAlterationObserver(org.apache.commons.io.monitor.FileAlterationObserver) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) FileAlterationMonitor(org.apache.commons.io.monitor.FileAlterationMonitor) IOFileFilter(org.apache.commons.io.filefilter.IOFileFilter) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Example 24 with IOFileFilter

use of org.apache.commons.io.filefilter.IOFileFilter in project jo-client-platform by jo-source.

the class TemplateReplacer method list.

private static Collection<File> list(final File dir, final IOFileFilter dirFilter) {
    final Collection<File> result = new LinkedList<File>();
    final IOFileFilter projectFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".project"));
    final IOFileFilter classpathFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".classpath"));
    final IOFileFilter checkstyleFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".checkstyle"));
    final IOFileFilter excludeFilesFilter = FileFilterUtils.and(projectFilter, classpathFilter, checkstyleFilter);
    final IOFileFilter noDirsFilter = FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE);
    final IOFileFilter fileFilter = FileFilterUtils.and(excludeFilesFilter, FileFilterUtils.or(noDirsFilter, dirFilter));
    listRecursive(result, dir, fileFilter);
    return result;
}
Also used : IOFileFilter(org.apache.commons.io.filefilter.IOFileFilter) File(java.io.File) LinkedList(java.util.LinkedList)

Example 25 with IOFileFilter

use of org.apache.commons.io.filefilter.IOFileFilter in project atlas by alibaba.

the class TPatchTool method doBundleResPatch.

public void doBundleResPatch(String bundleName, File destPatchBundleDir, File newBundleUnzipFolder, File baseBundleUnzipFolder) throws IOException {
    // compare resource changes
    Collection<File> newBundleResFiles = FileUtils.listFiles(newBundleUnzipFolder, new IOFileFilter() {

        @Override
        public boolean accept(File file) {
            // 不包括dex文件
            if (file.getName().endsWith(".dex")) {
                return false;
            }
            String relativePath = PathUtils.toRelative(newBundleUnzipFolder, file.getAbsolutePath());
            if (null != ((TpatchInput) (input)).notIncludeFiles && pathMatcher.match(((TpatchInput) (input)).notIncludeFiles, relativePath)) {
                return false;
            }
            return true;
        }

        @Override
        public boolean accept(File file, String s) {
            return accept(new File(file, s));
        }
    }, TrueFileFilter.INSTANCE);
    for (File newBundleResFile : newBundleResFiles) {
        String resPath = PathUtils.toRelative(newBundleUnzipFolder, newBundleResFile.getAbsolutePath());
        File baseBundleResFile = new File(baseBundleUnzipFolder, resPath);
        File destResFile = new File(destPatchBundleDir, resPath);
        if (baseBundleResFile.exists()) {
            if (isFileModify(newBundleResFile, baseBundleResFile, bundleName, resPath)) {
                // modify resource
                if (baseBundleResFile.getName().endsWith(".so")) {
                    if (((TpatchInput) input).diffNativeSo && ((TpatchInput) input).diffBundleSo) {
                        destResFile = new File(destPatchBundleDir, resPath.concat(".patch"));
                        SoDiffUtils.diffSo(baseBundleResFile.getParentFile(), baseBundleResFile, newBundleResFile, destResFile);
                    } else {
                        FileUtils.copyFile(newBundleResFile, destResFile);
                    }
                } else {
                    FileUtils.copyFile(newBundleResFile, destResFile);
                }
            }
        } else {
            // new resource
            FileUtils.copyFile(newBundleResFile, destResFile);
        }
    }
}
Also used : IOFileFilter(org.apache.commons.io.filefilter.IOFileFilter) TpatchFile(com.taobao.android.outputs.TpatchFile) ZipFile(java.util.zip.ZipFile) PatchFile(com.taobao.android.outputs.PatchFile)

Aggregations

IOFileFilter (org.apache.commons.io.filefilter.IOFileFilter)32 File (java.io.File)23 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)6 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)4 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)4 Test (org.junit.Test)4 BatchFile (org.kuali.kfs.sys.batch.BatchFile)4 URL (java.net.URL)3 PatchFile (com.taobao.android.outputs.PatchFile)2 TpatchFile (com.taobao.android.outputs.TpatchFile)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 ZipFile (java.util.zip.ZipFile)2 AndFileFilter (org.apache.commons.io.filefilter.AndFileFilter)2 DirectoryFileFilter (org.apache.commons.io.filefilter.DirectoryFileFilter)2 NotFileFilter (org.apache.commons.io.filefilter.NotFileFilter)2 FileAlterationMonitor (org.apache.commons.io.monitor.FileAlterationMonitor)2 FileAlterationObserver (org.apache.commons.io.monitor.FileAlterationObserver)2 Ignite (org.apache.ignite.Ignite)2