From 8ab26de8b047fde972c2ef5f26e4d1c1c53d7845 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 11 Aug 2003 20:34:21 +0000 Subject: [PATCH] Now that we're closing the jarfile after unpacking it, we can't be poking around in there for other reasons. We also avoid looking up the entry in the jar file every time it is requested. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2766 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/resource/ResourceBundle.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/java/com/threerings/resource/ResourceBundle.java b/src/java/com/threerings/resource/ResourceBundle.java index 93a77b424..13af2177f 100644 --- a/src/java/com/threerings/resource/ResourceBundle.java +++ b/src/java/com/threerings/resource/ResourceBundle.java @@ -1,5 +1,5 @@ // -// $Id: ResourceBundle.java,v 1.20 2003/08/09 05:42:13 mdb Exp $ +// $Id: ResourceBundle.java,v 1.21 2003/08/11 20:34:21 mdb Exp $ package com.threerings.resource; @@ -267,16 +267,14 @@ public class ResourceBundle return null; } - // make sure said resource exists in the first place - JarEntry entry = _jarSource.getJarEntry(path); - if (entry == null) { -// Log.info("Couldn't locate " + path + " in " + _jarSource + "."); - return null; - } - // if we have been unpacked, return our unpacked file if (_cache != null) { - return new File(_cache, path); + File cfile = new File(_cache, path); + if (cfile.exists()) { + return cfile; + } else { + return null; + } } // otherwise, we unpack resources as needed into a temp directory @@ -286,6 +284,12 @@ public class ResourceBundle return tfile; } + JarEntry entry = _jarSource.getJarEntry(path); + if (entry == null) { +// Log.info("Couldn't locate " + path + " in " + _jarSource + "."); + return null; + } + // copy the resource into the temporary file BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream(tfile)); @@ -322,8 +326,7 @@ public class ResourceBundle try { resolveJarFile(); return (_jarSource == null) ? "[file=" + _source + "]" : - "[path=" + _jarSource.getName() + - ", entries=" + _jarSource.size() + "]"; + "[path=" + _jarSource.getName() + "]"; } catch (IOException ioe) { return "[file=" + _source + ", ioe=" + ioe + "]";