1 package com.atlassian.plugin.util;
2
3 import com.atlassian.plugin.util.zip.UrlUnzipper;
4 import org.apache.commons.logging.Log;
5 import org.apache.commons.logging.LogFactory;
6
7 import java.io.File;
8 import java.io.IOException;
9 import java.net.URL;
10
11 public class FileUtils
12 {
13 private static final Log log = LogFactory.getLog(FileUtils.class);
14
15
16
17
18
19
20
21
22
23 public static void conditionallyExtractZipFile(URL zipUrl, File destDir)
24 {
25 try
26 {
27 UrlUnzipper unzipper = new UrlUnzipper(zipUrl, destDir);
28 unzipper.conditionalUnzip();
29 }
30 catch (IOException e)
31 {
32 log.error("Found " + zipUrl + ", but failed to read file", e);
33 }
34 }
35
36
37
38
39 public static void deleteDir(File directory)
40 {
41 try
42 {
43 org.apache.commons.io.FileUtils.deleteDirectory(directory);
44 } catch (IOException e)
45 {
46 log.error("Unable to delete directory: "+directory.getAbsolutePath(), e);
47 }
48 }
49
50 }