package baf.sci; import com.sun.java.swing.tree.TreeNode; import java.io.*; import java.util.*; /** This class represents a single SCI resource that has not been loaded * into memory. */ public final class ExternalResourceIndex extends ResourceIndex { /** Creates a ResourceIndex for an external file with the given * attributes. */ ExternalResourceIndex(int restype, int resnum) { this.restype = restype; this.resnum = resnum; } /** Creates a ResourceIndex for an external file with the given * name. */ ExternalResourceIndex(String filename) { int id = Resource.getID(filename); this.restype = Resource.getType(id); this.resnum = Resource.getNum(id); } public byte[] getArray() throws ResourceNotFoundException { try { InputStream in; int len; String filename = Resource.getName(restype, resnum); File file = new File(parent.parent.parent.file, filename); len = (int)(file.length()-2); in = new FileInputStream(file); in.skip(2); byte[] b = new byte[len]; new DataInputStream(in).readFully(b); return b; } catch (IOException e) { e.printStackTrace(); throw new ResourceNotFoundException(restype, resnum); } } }