diff --git a/src/java/com/threerings/resource/ResourceManager.java b/src/java/com/threerings/resource/ResourceManager.java index 3d7525a0d..57285755d 100644 --- a/src/java/com/threerings/resource/ResourceManager.java +++ b/src/java/com/threerings/resource/ResourceManager.java @@ -1,5 +1,5 @@ // -// $Id: ResourceManager.java,v 1.17 2002/10/25 17:21:00 mdb Exp $ +// $Id: ResourceManager.java,v 1.18 2002/11/20 02:00:36 mdb Exp $ package com.threerings.resource; @@ -486,6 +486,47 @@ public class ResourceManager throw new FileNotFoundException(errmsg); } + /** + * Returns an input stream from which the requested resource can be + * loaded. Note: this performs a linear search of all of the + * bundles in the set and returns the first resource found with the + * specified path, thus it is not extremely efficient and will behave + * unexpectedly if you use the same paths in different resource + * bundles. + * + * @exception FileNotFoundException thrown if the resource could not + * be located in any of the bundles in the specified set, or if the + * specified set does not exist. + * @exception IOException thrown if a problem occurs locating or + * reading the resource. + */ + public InputStream getResource (String rset, String path) + throws IOException + { + // grab the resource bundles in the specified resource set + ResourceBundle[] bundles = getResourceSet(rset); + if (bundles == null) { + throw new FileNotFoundException( + "Unable to locate resource [set=" + rset + + ", path=" + path + "]"); + } + + // look for the resource in any of the bundles + int size = bundles.length; + for (int ii = 0; ii < size; ii++) { + InputStream instr = bundles[ii].getResource(path); + if (instr != null) { +// Log.info("Found resource [rset=" + rset + +// ", bundle=" + bundles[ii].getSource().getPath() + +// ", path=" + path + "]."); + return instr; + } + } + + throw new FileNotFoundException( + "Unable to locate resource [set=" + rset + ", path=" + path + "]"); + } + /** * Returns a reference to the resource set with the specified name, or * null if no set exists with that name. Services that wish to load