From ead3a989b236cd649658b8b9bc96e2053bbb8edc Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 4 Apr 2006 18:46:42 +0000 Subject: [PATCH] Use the new FileUtil method. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3998 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/resource/ResourceBundle.java | 54 ++----------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/src/java/com/threerings/resource/ResourceBundle.java b/src/java/com/threerings/resource/ResourceBundle.java index c8f0ed5a9..b1133d1fc 100644 --- a/src/java/com/threerings/resource/ResourceBundle.java +++ b/src/java/com/threerings/resource/ResourceBundle.java @@ -28,11 +28,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import com.samskivert.io.StreamUtil; import com.samskivert.util.FileUtil; import com.samskivert.util.StringUtil; @@ -131,58 +129,14 @@ public class ResourceBundle FileUtil.recursiveClean(_cache); } - Enumeration entries = _jarSource.entries(); - while (entries.hasMoreElements()) { - JarEntry entry = (JarEntry)entries.nextElement(); - File efile = new File(_cache, entry.getName()); - - // if we're unpacking a normal jar file, it will have - // special path entries that allow us to create our - // directories first - if (entry.isDirectory()) { - if (!efile.exists() && !efile.mkdir()) { - Log.warning("Failed to create bundle entry path '" + - efile + "'."); - } - continue; - } - - // but some do not, so we want to ensure that our - // directories exist prior to getting down and funky - File parent = new File(efile.getParent()); - if (!parent.exists() && !parent.mkdirs()) { - Log.warning("Failed to create bundle entry parent '" + - parent + "'."); - continue; - } - - boolean failure = false; - BufferedOutputStream fout = null; - InputStream jin = null; - try { - fout = new BufferedOutputStream( - new FileOutputStream(efile)); - jin = _jarSource.getInputStream(entry); - CopyUtils.copy(jin, fout); - } catch (Exception e) { - Log.warning("Failure unpacking " + efile + ": " + e); - failure = true; - } finally { - StreamUtil.close(jin); - StreamUtil.close(fout); - } - + // unpack the jar file (this will close the jar when it's done) + if (!FileUtil.unpackJar(_jarSource, _cache)) { // if something went awry, delete everything in the hopes // that next time things will work - if (failure) { - wipeBundle(true); - return false; - } + wipeBundle(true); + return false; } - // close the jar file now that it's all unpacked - closeJar(); - // if everything unpacked smoothly, create our unpack stamp try { _unpacked.createNewFile();