use of org.apache.commons.io.filefilter.AndFileFilter 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.AndFileFilter in project tutorials by eugenp.
the class CommonsIOUnitTest method whenGetFilewith_ANDFileFilter_thenFindsampletxt.
@Test
public void whenGetFilewith_ANDFileFilter_thenFindsampletxt() throws IOException {
String path = getClass().getClassLoader().getResource("fileTest.txt").getPath();
File dir = FileUtils.getFile(FilenameUtils.getFullPath(path));
Assert.assertEquals("sample.txt", dir.list(new AndFileFilter(new WildcardFileFilter("*ple*", IOCase.INSENSITIVE), new SuffixFileFilter("txt")))[0]);
}
use of org.apache.commons.io.filefilter.AndFileFilter in project druid by druid-io.
the class LocalInputSource method getDirectoryListingIterator.
private Iterator<File> getDirectoryListingIterator() {
if (baseDir == null) {
return Collections.emptyIterator();
} else {
final IOFileFilter fileFilter;
if (files == null) {
fileFilter = new WildcardFileFilter(filter);
} else {
fileFilter = new AndFileFilter(new WildcardFileFilter(filter), new NotFileFilter(new NameFileFilter(files.stream().map(File::getName).collect(Collectors.toList()), IOCase.SENSITIVE)));
}
Iterator<File> fileIterator = FileUtils.iterateFiles(baseDir.getAbsoluteFile(), fileFilter, TrueFileFilter.INSTANCE);
if (!fileIterator.hasNext()) {
// base dir & filter are guaranteed to be non-null here
// (by construction and non-null check of baseDir a few lines above):
log.info("Local inputSource filter [%s] for base dir [%s] did not match any files", filter, baseDir);
}
return fileIterator;
}
}
use of org.apache.commons.io.filefilter.AndFileFilter in project oxTrust by GluuFederation.
the class ViewLogFileAction method prepareLogFiles.
private Map<Integer, String> prepareLogFiles() {
Map<Integer, String> logFiles = new HashMap<Integer, String>();
int fileIndex = 0;
for (SimpleCustomProperty logTemplate : this.logViewerConfiguration.getLogTemplates()) {
String logTemplatePattern = logTemplate.getValue2();
if (StringHelper.isEmpty(logTemplatePattern)) {
continue;
}
String logTemplatePath = FilenameUtils.getFullPath(logTemplatePattern);
String logTemplateFile = FilenameUtils.getName(logTemplatePattern);
File logTemplateBaseDir = new File(logTemplatePath);
FileFilter fileFilter = new AndFileFilter(FileFileFilter.FILE, new WildcardFileFilter(logTemplateFile));
File[] files = logTemplateBaseDir.listFiles(fileFilter);
if (files == null) {
continue;
}
for (int i = 0; i < files.length; i++) {
logFiles.put(fileIndex++, files[i].getPath());
}
}
return logFiles;
}
use of org.apache.commons.io.filefilter.AndFileFilter 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);
}
Aggregations