From 07fe0ec0c8f3b2bfa16bfc5a319697a5cbdf76fd Mon Sep 17 00:00:00 2001 From: jakebacker Date: Fri, 7 Sep 2018 13:59:04 -0400 Subject: [PATCH] Add full support for large files. Warning, does not automatically delete files yet --- src/main/java/Main.java | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 747ad94..bed231e 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -86,7 +86,7 @@ public boolean accept(File dir, String n) { break; } - File tempOutput = new File(f.getName()); + File tempOutput = new File(f.getName().substring(0, f.getName().lastIndexOf("." + StringUtils.getFileExtension(f)))); File tempInput = new File(f.getName()); // For some reason, ImageIO does not like the .\ in front @@ -135,8 +135,8 @@ public boolean accept(File dir, String n) { // If the last three bytes are 255, then you are in the right place firstIndex -= 3; } else { - lastIndex = data.length; - firstIndex = lastIndex - 19; + /*lastIndex = data.length; + firstIndex = lastIndex - 19;*/ } checksum = Arrays.copyOfRange(data, firstIndex + 1, firstIndex + 21); @@ -179,13 +179,33 @@ public boolean accept(File dir, String n) { Zipper zipper = new Zipper(); try { - zipper.unzip(files[0].getName()); + zipper.unzip(files[files.length-1].getName().substring(0, files[0].getName().lastIndexOf("." + StringUtils.getFileExtension(files[0])))); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("File does not exist!"); System.exit(1); + } catch (ZipException e) { + System.out.println("Unable to extract"); } + /*File[] delFiles = dir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + String noPng = files[files.length-1].getName().substring(0, files[0].getName().lastIndexOf("." + StringUtils.getFileExtension(files[0]))); + String noZip = noPng.substring(0, noPng.lastIndexOf(".")); + String lastThree = name.substring(name.length()-3); + + if (name.equals(noZip + "." + lastThree) & lastThree.charAt(0)=='z') { + return true; + } + return false; + } + }); + + for (File f : delFiles) { + f.delete(); + }*/ + long endTime = System.nanoTime(); double deltaTime = (double) (endTime - startTime) / 1000000000.0;