Révision 2482

tmp/org.txm.utils/src/org/txm/utils/zip/Zip.java (revision 2482)
70 70
	 *             Signals that an I/O exception has occurred.
71 71
	 */
72 72
	public static void compress(final File file) throws IOException {
73
		compress(file, file, DEFAULT_LEVEL_COMPRESSION, null);
73
		compress(file, file, DEFAULT_LEVEL_COMPRESSION, null, null);
74 74
	}
75 75

  
76 76
	/**
......
84 84
	 *             Signals that an I/O exception has occurred.
85 85
	 */
86 86
	public static void compress(final File file, final File target) throws IOException {
87
		compress(file, target, DEFAULT_LEVEL_COMPRESSION, null);
87
		compress(file, target, DEFAULT_LEVEL_COMPRESSION, null, null);
88 88
	}
89 89

  
90 90
	/**
......
97 97
	 * @throws IOException
98 98
	 *             Signals that an I/O exception has occurred.
99 99
	 */
100
	public static void compress(final File file, final File targetZipFile, IProgressMonitor monitor) throws IOException {
101
		compress(file, targetZipFile, DEFAULT_LEVEL_COMPRESSION, monitor);
100
	public static void compress(final File file, final File targetZipFile, IProgressMonitor monitor, HashSet<String> ignore) throws IOException {
101
		compress(file, targetZipFile, DEFAULT_LEVEL_COMPRESSION, monitor, ignore);
102 102
	}
103 103

  
104 104
	// Compresse un fichier à l'adresse pointée par le fichier cible.
......
116 116
	 * @throws IOException
117 117
	 *             Signals that an I/O exception has occurred.
118 118
	 */
119
	public static void compress(final File file, final File targetZipFile, final int compressionLevel, IProgressMonitor monitor) throws IOException {
119
	public static void compress(final File file, final File targetZipFile, final int compressionLevel, IProgressMonitor monitor, HashSet<String> ignore) throws IOException {
120 120
		final File source = file.getCanonicalFile();
121 121

  
122 122
		// Création du fichier zip
......
125 125
		out.setLevel(compressionLevel);
126 126

  
127 127
		// Ajout du(es) fichier(s) au zip
128
		compressFile(out, "", source, monitor);
128
		compressFile(out, "", source, monitor, ignore);
129 129
		out.close();
130 130
	}
131 131

  
......
140 140
	 *             Signals that an I/O exception has occurred.
141 141
	 */
142 142
	public static void compress(final File file, final int compressionLevel) throws IOException {
143
		compress(file, file, compressionLevel, null);
143
		compress(file, file, compressionLevel, null, null);
144 144
	}
145 145

  
146 146
	/**
......
152 152
	 *             Signals that an I/O exception has occurred.
153 153
	 */
154 154
	public static void compress(final String fileName) throws IOException {
155
		compress(new File(fileName), new File(fileName), DEFAULT_LEVEL_COMPRESSION, null);
155
		compress(new File(fileName), new File(fileName), DEFAULT_LEVEL_COMPRESSION, null, null);
156 156
	}
157 157

  
158 158
	/**
......
166 166
	 *             Signals that an I/O exception has occurred.
167 167
	 */
168 168
	public static void compress(final String fileName, final int compressionLevel) throws IOException {
169
		compress(new File(fileName), new File(fileName), compressionLevel, null);
169
		compress(new File(fileName), new File(fileName), compressionLevel, null, null);
170 170
	}
171 171

  
172 172
	/**
......
180 180
	 *             Signals that an I/O exception has occurred.
181 181
	 */
182 182
	public static void compress(final String fileName, final String targetName) throws IOException {
183
		compress(new File(fileName), new File(targetName), DEFAULT_LEVEL_COMPRESSION, null);
183
		compress(new File(fileName), new File(targetName), DEFAULT_LEVEL_COMPRESSION, null, null);
184 184
	}
185 185

  
186 186
	/**
......
196 196
	 *             Signals that an I/O exception has occurred.
197 197
	 */
198 198
	public static void compress(final String fileName, final String targetName, final int compressionLevel) throws IOException {
199
		compress(new File(fileName), new File(targetName), compressionLevel, null);
199
		compress(new File(fileName), new File(targetName), compressionLevel, null, null);
200 200
	}
201 201

  
202 202
	/**
......
211 211
	 * @throws IOException
212 212
	 *             Signals that an I/O exception has occurred.
213 213
	 */
214
	private final static void compressFile(final ZipOutputStream out, final String parentFolder, final File file, IProgressMonitor monitor) throws IOException {
214
	private final static void compressFile(final ZipOutputStream out, final String parentFolder, final File file, IProgressMonitor monitor, HashSet<String> ignore) throws IOException {
215 215
		final String zipName = new StringBuilder(parentFolder).append(file.getName()).append(file.isDirectory() ? '/' : "").toString();
216 216

  
217 217
		// Définition des attributs du fichier
......
228 228
				if (monitor != null)
229 229
					monitor.beginTask("Compressing " + file + " directory (" + files.length + " files).", files.length);
230 230
				for (final File f : files) {
231
					compressFile(out, zipName.toString(), f, null);
232
					if (monitor != null)
231
					if (ignore != null && ignore.contains(f.getName())) {
232
						// continue; // file is ignored
233
					} else {
234
						compressFile(out, zipName.toString(), f, null, null);
235
					}
236

  
237
					if (monitor != null) {
233 238
						monitor.worked(1);
239
					}
234 240
				}
235 241
				if (monitor != null)
236 242
					monitor.done();

Formats disponibles : Unified diff