# HG changeset patch # User Sascha L. Teichmann # Date 1367919991 -7200 # Node ID 26ae3267bb32a66adc1a51c79637294dabeb1787 # Parent dd412faf7b4d98cf36492c3018a2884f168d0680# Parent 6f6a5b229a7aa8097235b054247166a367c3adb6 Merged diff -r 6f6a5b229a7a -r 26ae3267bb32 artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/FileTools.java --- a/artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/FileTools.java Mon May 06 16:36:07 2013 +0200 +++ b/artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/FileTools.java Tue May 07 11:46:31 2013 +0200 @@ -9,6 +9,7 @@ import java.io.BufferedInputStream; import java.io.File; +import java.io.FileFilter; import java.io.IOException; import java.io.InputStream; import java.io.FileInputStream; @@ -313,6 +314,21 @@ return file.delete(); } + public static final FileFilter ACCEPT_ALL = new FileFilter() { + @Override + public boolean accept(File file) { + return true; + } + }; + + public static void createZipArchive( + File file, + OutputStream outputStream + ) + throws IOException + { + createZipArchive(file, outputStream, ACCEPT_ALL); + } /** * Put the given file or directory into a zip archive. @@ -324,13 +340,14 @@ */ public static void createZipArchive( File file, - OutputStream outputStream + OutputStream outputStream, + FileFilter filter ) throws IOException { ZipOutputStream out = new ZipOutputStream(outputStream); - if (file.isFile()) { + if (filter.accept(file) && file.isFile()) { copyFileToZip("", file, out); } else if (file.isDirectory()) { @@ -345,7 +362,7 @@ out.putNextEntry(dirEntry); out.closeEntry(); - File [] files = pd.dir.listFiles(); + File [] files = pd.dir.listFiles(filter); if (files != null) { for (File sub: files) { if (sub.isDirectory()) {