KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > pluggable > impl > ZipStorage


1 /*
2  * ZipWriter.java
3  *
4  * Created on December 19, 2003, 11:39 PM
5  */

6
7 package com.sun.enterprise.config.backup.pluggable.impl;
8
9 import java.io.IOException JavaDoc;
10 import java.io.File JavaDoc;
11 import com.sun.enterprise.config.backup.BackupException;
12 import com.sun.enterprise.config.backup.BackupAbortException;
13 import com.sun.enterprise.config.backup.status.Status;
14 import com.sun.enterprise.config.backup.utils.FactoryHelper;
15 import com.sun.enterprise.config.backup.utils.LoggerHelper;
16 import com.sun.enterprise.util.io.FileUtils;
17 import com.sun.enterprise.util.zip.ZipWriter;
18 import com.sun.enterprise.util.zip.ZipFileException;
19 import com.sun.enterprise.util.StringUtils;
20
21 import com.sun.enterprise.config.backup.pluggable.BackupStorage;
22 /**
23  *
24  * @author sridatta
25  */

26 public class ZipStorage extends GenericStorage
27 {
28     /**
29     * creates a zip file in the specified directory
30     * @return int size of the zip that was just created
31     */

32     long copyFiles(File JavaDoc fromDir, File JavaDoc toDir) throws BackupException
33     {
34         File JavaDoc zip = new File JavaDoc(toDir.getAbsolutePath() + ".zip");
35         LoggerHelper.fine("Writing " + zip.getPath());
36         
37         try
38         {
39             ZipWriter writer = new ZipWriter(zip.getPath(), fromDir.getPath());
40             writer.safeWrite();
41             return zip.length();
42         }
43         catch(ZipFileException zfe)
44         {
45             throw new BackupException("Zip Backup Error", "Got a ZipFileException", zfe);
46         }
47     }
48 }
49
Popular Tags