[jsword-svn] common/java/core/org/crosswire/common/util s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Tue Jan 25 17:57:30 MST 2005


Update of /cvs/jsword/common/java/core/org/crosswire/common/util
In directory www.crosswire.org:/tmp/cvs-serv4935/java/core/org/crosswire/common/util

Modified Files:
	IOUtil.java 
Log Message:
Fixed a couple of bugs.

Index: IOUtil.java
===================================================================
RCS file: /cvs/jsword/common/java/core/org/crosswire/common/util/IOUtil.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IOUtil.java	28 Nov 2004 21:36:31 -0000	1.2
--- IOUtil.java	26 Jan 2005 00:57:27 -0000	1.3
***************
*** 5,8 ****
--- 5,9 ----
  import java.io.InputStream;
  import java.io.OutputStream;
+ import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.Enumeration;
***************
*** 44,53 ****
  
      /**
!      * Unpack a zip file to a given directory
       * @param file The zip file to download
       * @param destdir The directory to unpack up
       * @throws IOException If there is an file error
       */
!     public static void unpackZip(File file, URL destdir) throws IOException
      {
          // unpack the zip.
--- 45,55 ----
  
      /**
!      * Unpack a zip file to a given directory. Honor the paths
!      * as given in the zip file.
       * @param file The zip file to download
       * @param destdir The directory to unpack up
       * @throws IOException If there is an file error
       */
!     public static void unpackZip(File file, File destdir) throws IOException
      {
          // unpack the zip.
***************
*** 59,64 ****
              ZipEntry entry = (ZipEntry) entries.nextElement();
              String entrypath = entry.getName();
!             String filename = entrypath.substring(entrypath.lastIndexOf('/') + 1);
!             URL child = NetUtil.lengthenURL(destdir, filename);
  
              OutputStream dataOut = NetUtil.getOutputStream(child);
--- 61,79 ----
              ZipEntry entry = (ZipEntry) entries.nextElement();
              String entrypath = entry.getName();
!             File entryFile = new File(destdir, entrypath);
!             File parentDir = entryFile.getParentFile();
!             // Is it already a directory ?
!             if (!parentDir.isDirectory())
!             {
!                 parentDir.mkdirs();
! 
!                 // Did that work?
!                 if (!parentDir.isDirectory())
!                 {
!                     throw new MalformedURLException(Msg.CREATE_DIR_FAIL.toString(parentDir.toString()));
!                 }
!             }
! 
!             URL child = NetUtil.getURL(entryFile);
  
              OutputStream dataOut = NetUtil.getOutputStream(child);



More information about the jsword-svn mailing list