target = currentFolder + targetFolder;
}
String relativeTarget = target;
target = getBaseDir(request) + target;
JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
JSONEscapeObject.put("folder", relativeTarget);
Vector<JSONEscapeObject> folderList = new Vector<JSONEscapeObject>();
String tokens[] = relativeTarget.split("/");
String folder = "/";
for (int i = 0; i < tokens.length; i++) {
if (tokens[i].length() == 0) {
continue;
}
JSONEscapeObject jsonLevel = new JSONEscapeObject();
jsonLevel.put("name", tokens[i]);
if (folder.length() > 1) {
folder += "/";
}
folder += tokens[i];
jsonLevel.put("folder", folder);
folderList.add(jsonLevel);
}
JSONEscapeObject.put("breadcrumb", folderList);
File file = new File(target);
File entries[] = file.listFiles();
Vector<JSONEscapeObject> files = new Vector<JSONEscapeObject>();
for (int i = 0; i < entries.length; i++) {
File entry = entries[i];
if (!entry.isDirectory()) {
continue;
}
JSONEscapeObject jsonFile = new JSONEscapeObject();
jsonFile.put("name", entry.getName());
jsonFile.put("isDirectory", entry.isDirectory());
jsonFile.put("size", entry.length());
jsonFile.put("isImage", false);
Date lastUpdateOn = new Date(entry.lastModified());
jsonFile.put("lastUpdateOn", Format.getFullDatetime(lastUpdateOn));
files.add(jsonFile);
}
for (int i = 0; i < entries.length; i++) {
File entry = entries[i];
if (entry.isDirectory()) {
continue;
}
JSONEscapeObject jsonFile = new JSONEscapeObject();
jsonFile.put("name", entry.getName());
jsonFile.put("isDirectory", entry.isDirectory());
jsonFile.put("size", entry.length());
if (isImage(entry.getName())) {
jsonFile.put("isImage", true);
}
else {
jsonFile.put("isImage", false);
}
Date lastUpdateOn = new Date(entry.lastModified());
jsonFile.put("lastUpdateOn", Format.getFullDatetime(lastUpdateOn));
files.add(jsonFile);
}
JSONEscapeObject.put("files", files);
result = JSONEscapeObject.toHtmlString();