Révision 3529
TXM/trunk/org.txm.utils/src/org/txm/utils/zip/Zip.java (revision 3529) | ||
---|---|---|
54 | 54 |
*/ |
55 | 55 |
public class Zip { |
56 | 56 |
|
57 |
/** The ZIP extension. */ |
|
58 |
@Deprecated |
|
59 |
public static String ZIP_EXTENSION = ".odt"; // no more used, stay for old groovy script compatibility
|
|
57 |
// /** The ZIP extension. */
|
|
58 |
// @Deprecated
|
|
59 |
// public static String ZIP_EXTENSION = ".odt"; // no more used, stay for old Groovy script compatibility ?
|
|
60 | 60 |
|
61 | 61 |
/** The DEFAUL level of compression. */ |
62 |
private static int DEFAULT_LEVEL_COMPRESSION = Deflater.BEST_COMPRESSION;
|
|
62 |
public static int DEFAULT_LEVEL_COMPRESSION = Deflater.BEST_COMPRESSION;
|
|
63 | 63 |
|
64 | 64 |
/** |
65 | 65 |
* Compress. |
... | ... | |
130 | 130 |
* @throws IOException |
131 | 131 |
* Signals that an I/O exception has occurred. |
132 | 132 |
*/ |
133 |
public static void compress(final File file, final File targetZipFile, final int compressionLevel, IProgressMonitor monitor, HashSet<String> ignore) throws IOException { |
|
134 |
final File source = file.getCanonicalFile(); |
|
133 |
public static void compress(final File[] files, final File targetZipFile, final int compressionLevel, IProgressMonitor monitor, HashSet<String> ignore) throws IOException { |
|
135 | 134 |
|
135 |
|
|
136 | 136 |
// Création du fichier zip |
137 | 137 |
final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(targetZipFile)); |
138 | 138 |
out.setMethod(ZipOutputStream.DEFLATED); |
139 | 139 |
out.setLevel(compressionLevel); |
140 | 140 |
|
141 |
// Ajout du(es) fichier(s) au zip |
|
142 |
compressFile(out, "", source, monitor, ignore); |
|
141 |
for (File file : files) { |
|
142 |
// Ajout du(es) fichier(s) au zip |
|
143 |
final File source = file.getCanonicalFile(); |
|
144 |
compressFile(out, "", source, monitor, ignore); |
|
145 |
} |
|
143 | 146 |
out.close(); |
144 | 147 |
} |
145 | 148 |
|
149 |
// Compresse un fichier à l'adresse pointée par le fichier cible. |
|
150 |
// Remplace le fichier cible s'il existe déjà. |
|
146 | 151 |
/** |
152 |
* Compresse un fichier à l'adresse pointée par le fichier cible. Remplace le |
|
153 |
* fichier cible s'il existe déjà.. |
|
154 |
* |
|
155 |
* @param file |
|
156 |
* the file |
|
157 |
* @param targetZipFile |
|
158 |
* the target |
|
159 |
* @param compressionLevel |
|
160 |
* the compression level |
|
161 |
* @throws IOException |
|
162 |
* Signals that an I/O exception has occurred. |
|
163 |
*/ |
|
164 |
public static void compress(final File file, final File targetZipFile, final int compressionLevel, IProgressMonitor monitor, HashSet<String> ignore) throws IOException { |
|
165 |
compress(new File[] {file}, targetZipFile, compressionLevel, monitor, ignore); |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
147 | 169 |
* Compress. |
148 | 170 |
* |
149 | 171 |
* @param file |
Formats disponibles : Unified diff