diff --git a/app/src/main/java/org/acme/BrowseFilesResource.java b/app/src/main/java/org/acme/BrowseFilesResource.java
index c826ad5..094652a 100644
--- a/app/src/main/java/org/acme/BrowseFilesResource.java
+++ b/app/src/main/java/org/acme/BrowseFilesResource.java
@@ -1,5 +1,6 @@
package org.acme;
+import com.retroio.tools.*;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.ws.rs.GET;
@@ -24,13 +25,25 @@ public class BrowseFilesResource {
@Produces("text/html")
public Response browse(@QueryParam("path") String path, @QueryParam("image") String imageName) {
File pathDir = new File(uploadDirectory, path);
+ String baseDirName = path.substring(0, path.indexOf("/"));
+ File baseDir = new File(uploadDirectory, baseDirName);
+ File imageFile = new File(baseDir, imageName);
+ System.out.println("Image file: " + imageFile.getAbsolutePath());
+ ImageHandler imageHandler = ImageHandlerFactory.get(ImageType.getTypeFromFile(imageFile));
+ VirtualDisk virtualDisk;
+ try {
+ virtualDisk = imageHandler.loadImage(imageFile);
+ } catch (VirtualDiskException e) {
+ e.printStackTrace();
+ return Response.status(500).build();
+ }
String body = "\n
\n";
body += " \n";
body += " \n";
body += " RetroIO Floppy Image Browser\n";
body += "\n";
- body += createHeaderDiv(path, imageName);
+ body += createHeaderDiv(path, imageName, virtualDisk);
body += "
Contents
\n";
body += "
";
@@ -42,13 +55,15 @@ public Response browse(@QueryParam("path") String path, @QueryParam("image") Str
return Response.status(200).entity(body).build();
}
- private String createHeaderDiv(String path, String filename) {
+ private String createHeaderDiv(String path, String filename, VirtualDisk virtualDisk) {
String headerDiv = "
\n";
+ headerDiv += "
";
headerDiv += "";
headerDiv += "";
+ headerDiv += "";
- headerDiv += "
Image: " + filename + "
\n";
+ headerDiv += "
Image: " + filename + " / Platform: " + virtualDisk.getType().getPlatform() + "
\n";
headerDiv += "
\n";
headerDiv += "- Download as ZIP
\n";
diff --git a/app/src/main/java/org/acme/FloppyImageUploadResource.java b/app/src/main/java/org/acme/FloppyImageUploadResource.java
index 8a78620..143ab26 100644
--- a/app/src/main/java/org/acme/FloppyImageUploadResource.java
+++ b/app/src/main/java/org/acme/FloppyImageUploadResource.java
@@ -55,15 +55,6 @@ public Response uploadFile(MultipartFormDataInput input) {
Map> uploadForm = input.getFormDataMap();
boolean isAjax = uploadForm.containsKey("ajax");
- for(String key : uploadForm.keySet()) {
- System.out.println(">> KEY: " + key);
- for(InputPart value : uploadForm.get(key)) {
- System.out.println("-----> PART: ");
- for(String header : value.getHeaders().keySet()) {
- System.out.println("------> header: " + header + ": " + value.getHeaders().get(key));
- }
- }
- }
List inputParts = uploadForm.get("files[]");
for (InputPart inputPart : inputParts) {
@@ -77,7 +68,6 @@ public Response uploadFile(MultipartFormDataInput input) {
if(fileName != null && fileName.contains(".")) {
File finalImageFile = new File(finalDir, fileName);
ImageType imageType = ImageType.getTypeFromFile(finalImageFile);
- System.out.println("Image type: " + imageType.name());
if(imageType == ImageType.unknown) {
if(!isAjax) {
return Response.status(500).entity("Invalid/unsupported file format").build();
@@ -87,9 +77,7 @@ public Response uploadFile(MultipartFormDataInput input) {
}
try {
- System.out.println("********** FILENAME: " + fileName);
for (InputPart inputPart : inputParts) {
- System.out.println("> process part...");
MultivaluedMap header = inputPart.getHeaders();
// convert the uploaded file to inputstream
@@ -98,7 +86,6 @@ public Response uploadFile(MultipartFormDataInput input) {
writeFile(bytes, finalImageFile);
}
-
File unpackDir = new File(finalDir, fileName + "-unpacked");
unpackDir.mkdirs();
@@ -106,12 +93,7 @@ public Response uploadFile(MultipartFormDataInput input) {
VirtualDisk virtualDisk = imageHandler.loadImage(finalImageFile);
virtualDisk.exportToDirectory(unpackDir);
- System.out.println("Done");
-
URI uri = URI.create("/files/browse?path=" + uuid + "/" + unpackDir.getName() + "&image=" + fileName);
-
- System.out.println("------------- IS AJAX CLIENT: " + isAjax);
-
if(!isAjax) {
return Response.status(302).location(uri).build();
} else {
@@ -123,10 +105,8 @@ public Response uploadFile(MultipartFormDataInput input) {
return Response.status(500).entity("Unknown error: " + e).build();
}
- } else {
- System.err.println("------> Unable to find filename");
}
-System.err.println("------> FAILURE");
+
return Response.status(500).entity("Upload failed.").build();
}
diff --git a/app/src/main/java/org/acme/FolderNode.java b/app/src/main/java/org/acme/FolderNode.java
index b0498d3..f4b2d12 100644
--- a/app/src/main/java/org/acme/FolderNode.java
+++ b/app/src/main/java/org/acme/FolderNode.java
@@ -34,8 +34,8 @@ public FolderNode(String basePath, File folder, String parentPath) {
}
public String getFolderDivTag() {
- String divTag = "\n";
- divTag += "
" + this.title + "/\n";
+ String divTag = "
\n";
+ divTag += "
" + this.title + "/\n";
divTag += "
\n";
File[] files = this.folder.listFiles();
divTag += "