Search in sources :

Example 1 with PrefixFileFilter

use of org.apache.commons.io.filefilter.PrefixFileFilter in project robovm by robovm.

the class IOSTarget method copyToIndexedDir.

/**
     * Copies the dSYM and the executable to {@code ~/Library/Developer/Xcode/
     * DerivedData/RoboVM/Build/Products/<appname>_<timestamp>/}.
     */
private void copyToIndexedDir(File dir, String executable, File dsymDir, File exePath) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    final File indexedDir = new File(System.getProperty("user.home"), "Library/Developer/Xcode/DerivedData/RoboVM/Build/Products/" + FilenameUtils.removeExtension(dir.getName()) + "_" + sdf.format(new Date()));
    indexedDir.mkdirs();
    File indexedDSymDir = new File(indexedDir, dsymDir.getName());
    File indexedAppDir = new File(indexedDir, dir.getName());
    indexedAppDir.mkdirs();
    try {
        // No need to copy the whole .app folder. Just the exe
        // is enough to make symbolication happy.
        FileUtils.copyFile(exePath, new File(indexedAppDir, executable));
    } catch (IOException e) {
        config.getLogger().error("Failed to copy %s to indexed dir %s: %s", exePath.getAbsolutePath(), indexedAppDir.getAbsolutePath(), e.getMessage());
    }
    try {
        FileUtils.copyDirectory(dsymDir, indexedDSymDir);
    } catch (IOException e) {
        config.getLogger().error("Failed to copy %s to indexed dir %s: %s", dsymDir.getAbsolutePath(), indexedDir.getAbsolutePath(), e.getMessage());
    }
    // Now do some cleanup and delete all but the 3 most recent dirs
    List<File> dirs = new ArrayList<>(Arrays.asList(indexedDir.getParentFile().listFiles((FileFilter) new AndFileFilter(new PrefixFileFilter(FilenameUtils.removeExtension(dir.getName())), new RegexFileFilter(".*_\\d{14}")))));
    Collections.sort(dirs, new Comparator<File>() {

        public int compare(File o1, File o2) {
            return Long.compare(o1.lastModified(), o2.lastModified());
        }
    });
    if (dirs.size() > 3) {
        for (File f : dirs.subList(0, dirs.size() - 3)) {
            try {
                FileUtils.deleteDirectory(f);
            } catch (IOException e) {
                config.getLogger().error("Failed to delete diretcory %s", f.getAbsolutePath(), e.getMessage());
            }
        }
    }
}
Also used : AndFileFilter(org.apache.commons.io.filefilter.AndFileFilter) ArrayList(java.util.ArrayList) RegexFileFilter(org.apache.commons.io.filefilter.RegexFileFilter) IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date) PrefixFileFilter(org.apache.commons.io.filefilter.PrefixFileFilter)

Example 2 with PrefixFileFilter

use of org.apache.commons.io.filefilter.PrefixFileFilter in project libresonic by Libresonic.

the class TranscodingService method isTranscodingStepInstalled.

private boolean isTranscodingStepInstalled(String step) {
    if (StringUtils.isEmpty(step)) {
        return true;
    }
    String executable = StringUtil.split(step)[0];
    PrefixFileFilter filter = new PrefixFileFilter(executable);
    String[] matches = getTranscodeDirectory().list(filter);
    return matches != null && matches.length > 0;
}
Also used : PrefixFileFilter(org.apache.commons.io.filefilter.PrefixFileFilter)

Example 3 with PrefixFileFilter

use of org.apache.commons.io.filefilter.PrefixFileFilter in project robovm by robovm.

the class IOSTarget method packageApplication.

private void packageApplication(File appDir) throws IOException {
    File ipaFile = new File(config.getInstallDir(), getExecutable() + ".ipa");
    config.getLogger().info("Packaging IPA %s from %s", ipaFile.getName(), appDir.getName());
    File tmpDir = new File(config.getInstallDir(), "ipabuild");
    FileUtils.deleteDirectory(tmpDir);
    tmpDir.mkdirs();
    File payloadDir = new File(tmpDir, "Payload");
    payloadDir.mkdir();
    config.getLogger().info("Copying %s to %s", appDir.getName(), payloadDir);
    new Executor(config.getLogger(), "cp").args("-Rp", appDir, payloadDir).exec();
    File frameworksDir = new File(appDir, "Frameworks");
    if (frameworksDir.exists()) {
        String[] swiftLibs = frameworksDir.list(new AndFileFilter(new PrefixFileFilter("libswift"), new SuffixFileFilter(".dylib")));
        if (swiftLibs.length > 0) {
            File swiftSupportDir = new File(tmpDir, "SwiftSupport");
            swiftSupportDir.mkdir();
            copySwiftLibs(Arrays.asList(swiftLibs), swiftSupportDir);
        }
    }
    config.getLogger().info("Zipping %s to %s", tmpDir, ipaFile);
    new Executor(Logger.NULL_LOGGER, "zip").wd(tmpDir).args("--symlinks", "--recurse-paths", ipaFile, ".").exec();
    config.getLogger().info("Deleting temp dir %s", tmpDir);
    FileUtils.deleteDirectory(tmpDir);
}
Also used : Executor(org.robovm.compiler.util.Executor) AndFileFilter(org.apache.commons.io.filefilter.AndFileFilter) SuffixFileFilter(org.apache.commons.io.filefilter.SuffixFileFilter) NSString(com.dd.plist.NSString) File(java.io.File) PrefixFileFilter(org.apache.commons.io.filefilter.PrefixFileFilter)

Example 4 with PrefixFileFilter

use of org.apache.commons.io.filefilter.PrefixFileFilter in project cas by apereo.

the class UrlResourceMetadataResolver method cleanUpExpiredBackupMetadataFilesFor.

private void cleanUpExpiredBackupMetadataFilesFor(final AbstractResource metadataResource, final SamlRegisteredService service) {
    val prefix = getBackupMetadataFilenamePrefix(metadataResource, service);
    val backups = FileUtils.listFiles(this.metadataBackupDirectory, new AndFileFilter(CollectionUtils.wrapList(new PrefixFileFilter(prefix, IOCase.INSENSITIVE), new SuffixFileFilter(FILENAME_EXTENSION_XML, IOCase.INSENSITIVE), CanWriteFileFilter.CAN_WRITE, CanReadFileFilter.CAN_READ)), TrueFileFilter.INSTANCE);
    backups.forEach(Unchecked.consumer(FileUtils::forceDelete));
}
Also used : lombok.val(lombok.val) AndFileFilter(org.apache.commons.io.filefilter.AndFileFilter) SuffixFileFilter(org.apache.commons.io.filefilter.SuffixFileFilter) PrefixFileFilter(org.apache.commons.io.filefilter.PrefixFileFilter)

Aggregations

PrefixFileFilter (org.apache.commons.io.filefilter.PrefixFileFilter)4 AndFileFilter (org.apache.commons.io.filefilter.AndFileFilter)3 File (java.io.File)2 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)2 NSString (com.dd.plist.NSString)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 lombok.val (lombok.val)1 RegexFileFilter (org.apache.commons.io.filefilter.RegexFileFilter)1 Executor (org.robovm.compiler.util.Executor)1