void showProperties(String fileName) {
try {
if (fileName.equals(UP_DIRECTORY))
return;
FileConnection fc = (FileConnection) Connector.open("file://localhost/" + currDirName + fileName);
if (!fc.exists())
throw new IOException(T._("File does not exists."));
Form props = new Form(T._("Properties") + ": " + fileName);
props.addCommand(backToBCommand);
props.setCommandListener(this);
props.append(new StringItem(T._("Location"), currDirName));
props.append(new StringItem(T._("Type"), fc.isDirectory() ? T._("Directory") : T._("Regular File")));
props.append(new StringItem(T._("Size"), Long.toString((fc.isDirectory() ? fc.directorySize(true) : fc.fileSize()))));
props.append(new StringItem(T._("Modified"), myDate(fc.lastModified())));
ChoiceGroup attrs = new ChoiceGroup(T._("Attributes"), Choice.MULTIPLE, attrList, null);
attrs.setSelectedFlags(new boolean[] { fc.canRead(), fc.canWrite(), fc.isHidden() });
props.append(attrs);
if (fileName.toLowerCase().endsWith(".sgf"))
try {
StringBuffer sb = new StringBuffer();
InputStream is = fc.openInputStream();
InputStreamReader isr = new InputStreamReader(is);
SGFParser parser = new SGFParser(isr);
SGFNode head = parser.parseHead();
is.close();
for (Enumeration e = head.getProperties(); e.hasMoreElements(); ) {
sb.append(e.nextElement().toString());
sb.append("\n");
}
props.append(new StringItem(T._("SGF Header"), sb.toString()));
} catch (Exception e) {
}
fc.close();
display.setCurrent(props);
} catch (Exception e) {
Alert alert = new Alert(T._("Error!"), T._("Can't access file ") + fileName
+ T._(" in directory ") + currDirName + "\n" + T._("Exception: ")
+ e.getMessage(), null, AlertType.ERROR);