private Res parent;
Zip(Res parent) { this.parent = parent; }
public InputStream getInputStream(String path) throws IOException {
+ if (path.startsWith("/")) path = path.substring(1);
ZipInputStream zis = new ZipInputStream(parent.getInputStream());
ZipEntry ze = zis.getNextEntry();
while(ze != null && !ze.getName().equals(path)) ze = zis.getNextEntry();
- if (ze == null) throw new JS.Exn("zip file not found in archive");
+ if (ze == null) throw new JS.Exn("requested file not found in archive");
return zis;
}
}
Object key;
Ref(Res parent, Object key) { this.parent = parent; this.key = key; }
public Res addExtension(String extension) {
- return (key instanceof String && ((String)key).endsWith(extension)) ? this : new Ref(this, extension);
+ return (key instanceof String && ((String)key).endsWith(extension)) ? this : new Ref(parent, key + extension);
}
public InputStream getInputStream(String path) throws IOException {
return parent.getInputStream("/" + key + path);