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
This commit is contained in:
Michael Bayne
2003-08-11 20:34:21 +00:00
parent cb89eaf73d
commit 8ab26de8b0
@@ -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 + "]";