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());
}
}
}
}
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;
}
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);
}
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));
}
Aggregations