diff --git a/FileInfo.java b/FileInfo.java index a6dfe52..7af8999 100644 --- a/FileInfo.java +++ b/FileInfo.java @@ -17,7 +17,7 @@ public class FileInfo implements Comparable { private File file; // file information private String name; // filename private Path path; // file path - private String md5; // md5 hash + private String hash; private Directory dir; // directory that the file is in private int num; // the file id in this directory private boolean repeated; // flag to be used in internal repetion handling @@ -40,16 +40,16 @@ public FileInfo(File file, Directory dir) { this.dir = dir; this.name = file.getName(); try { - calculateMD5(); + calculateHash(); } catch (NoSuchAlgorithmException | IOException e) { e.printStackTrace(); } y++; - System.out.println(" MD5: " + md5); + System.out.println(" MD5: " + hash); } // calculates the md5 hash of this file - public void calculateMD5() throws NoSuchAlgorithmException, IOException { + public void calculateHash() throws NoSuchAlgorithmException, IOException { InputStream fis = new FileInputStream(path.toString()); byte[] buffer = new byte[1024]; @@ -75,7 +75,7 @@ public void calculateMD5() throws NoSuchAlgorithmException, IOException { sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1)); } - md5 = sb.toString(); + hash = sb.toString(); } /** @@ -95,8 +95,8 @@ public Path getPath() { /** * @return the md5 hash of this file */ - public String getMD5() { - return this.md5; + public String getHash() { + return this.hash; } /** @@ -148,7 +148,7 @@ public void setRepeated() { * Used to compare files to find repetions */ public int compareTo(FileInfo file) { - return md5.compareTo(file.getMD5()); + return hash.compareTo(file.getHash()); } } diff --git a/Main.java b/Main.java index 786133b..f6f9e7c 100644 --- a/Main.java +++ b/Main.java @@ -19,8 +19,6 @@ public class Main { private ArrayList dirs; // where all directories are stored private ArrayList files; // where all files will be stored for comparasion private ArrayList subfolders; // stores the subfolders of the Results folder - private ArrayList internalRepetions; // used in internal repetion handling, this - // still in the works private HashMap letters; // used to translate the directory number in a letter to use in the // filenames @@ -33,7 +31,6 @@ public Main(String[] args) { dirs = new ArrayList(); files = new ArrayList(); subfolders = new ArrayList(); - internalRepetions = new ArrayList(); // not used yet letters = new HashMap(26); setLetters(); // fills the HashMap diff --git a/README.md b/README.md index efb5e8b..bb63dd8 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Theres a libray in the internet called FastMD5. It's a fast and super optimizade 3. **There's a way to rename them quickly?** - You can use my [renamer tool here](https://github.com/FlyingWolFox/Duplicate-Finder-Renamer/)) that is made to work with this tool, use another tool like Bulk Renaming Utility or a shell script/batch file + You can use my [renamer tool here](https://github.com/FlyingWolFox/Duplicate-Finder-Renamer/) that is made to work with this tool, use another tool like Bulk Renaming Utility or a shell script/batch file 4. **The tools rise an exception/error, what should I do?** @@ -94,11 +94,11 @@ You can help createing an Issue or a Pull Request, I'll look into it, I promise! 3. **I want to put FastMD5 in the code, where I change?** -The method `calculateMD5()` in the ROM class is responsible to calculate the MD5 hash so any modifications in the hash calculation goes there. The method just change the `String md5` variable to contain the hash. However I don't know how to implement FastMD5, but I may try in the future. +The method `calculateHash()` in the FileInfo class is responsible to calculate the hash so any modifications in the hash calculation goes there. The method changes the `String hash` variable to contain the hash. 4. **Why not use other hashing algorithm or use multiple ones?** -I choosed MD5 because is relatively colision safe when looking for repeated files and it's fast. There was other alternatives, like SHA-1, that's fast too, but MD5 was good enough. Other hashes like SHA-2 or SHA-3 weren't considered because they're really slow. Other non-security algorithms weren't considered because I didn't know they existed until yesterday :D You can put any hash you want in the code and it'll work. I'm thinking of changing `calculateMD5()` to `calculateHash()` to make the use of other algorithms easier +I choosed MD5 because is relatively colision safe when looking for repeated files and it's fast. There was other alternatives, like SHA-1, that's fast too, but MD5 was good enough. Other hashes like SHA-2 or SHA-3 weren't considered because they're really slow. Other non-security algorithms weren't considered because I didn't know they existed until sometime ago :D You can put any hash you want in the code and it'll work. 5. **Everything is in the Main class in a weird way, how the code is designed?** @@ -106,9 +106,4 @@ This is because this tool is more like a script, so things went to the Main clas ## Future plans -This tool isn't finished, not for me at least, so I'm planning to do: - -- [ ] Implement a compressed archived comparer -- [ ] Better verbosity - -Also I'm planning to make a GUI version of this tool (when I learn how to make GUIs) to be even better! It'll be in another repository tho. I'll update here when I finish it +I'm planning to make a GUI version of this tool (when I learn how to make GUIs) to be even better! It'll be in another repository tho. I'll update here when I finish it