g.append("<p><a href=\"..\">Parent</a><br>");
}
// List the children:
for (int i = 0 ; i < resources.size() ; i++) {
String name = (String) resources.elementAt(i);
ResourceReference rr = null;
long size = -1;
rr = cresource.lookup(name);
FramedResource resource = null;
if (rr != null) {
try {
resource = (FramedResource) rr.unsafeLock();
// remove manually deleted FileResources
if( resource instanceof FileResource ) {
FileResource fr = (FileResource)resource;
if( !fr.getFile().exists() ) {
try {
fr.delete();
} catch (MultipleLockException ex) {};
continue;
} else {
size = fr.getFile().length();
}
}
HTTPFrame itsframe = null;
if (http_class != null)
itsframe =
(HTTPFrame) resource.getFrame(http_class);
if (itsframe != null) {
// Icon first, if available
String icon = itsframe.getIcon() ;
if ( icon != null ) {
g.append("<img src=\""+
getIconDirectory() +"/"+ icon+
"\" alt=\"" + icon + "\">");
}
// Resource's name with link:
if (resource instanceof ContainerInterface) {
g.append("<a href=\""
, URLEncoder.encode(name)
, "/\">"+name+"</a>");
} else {
g.append("<a href=\""
, URLEncoder.encode(name)
, "\">"+name+"</a>");
}
// resource's title, if any:
String title = itsframe.getTitle();
if ( title != null ) {
g.append(" "+title);
}
//size (if any)
if (size != -1) {
String s = null;
if (size > 1023) {
s = " ["+(size/1024)+" KB]";
} else {
s = " ["+size+" bytes]";
}
g.append(s);
}
g.append("<br>\n");
} else {
// Resource's name with link:
g.append(name+
" (<i>Not available via HTTP.</i>)");
g.append("<br>\n");
}
} catch (InvalidResourceException ex) {
g.append(name+
" cannot be loaded (server misconfigured)");
g.append("<br>\n");
continue;
} finally {
rr.unlock();
}
}
}
g.close() ;
listing_stamp = getLastModified() ;