Skip to content

Commit

Permalink
Add full support for large files.
Browse files Browse the repository at this point in the history
Warning, does not automatically delete files yet
  • Loading branch information
UnknownSilicon committed Sep 7, 2018
1 parent b4ba424 commit 07fe0ec
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 07fe0ec

Please sign in to comment.