diff --git a/.gitignore b/.gitignore
index 0e44c83..62b81cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,5 +28,5 @@ bin/
### Mac OS ###
.DS_Store
-### Compile via Instructions ###
-Bin/
+### Maven ###
+target/
diff --git a/.idea/artifacts/Sherly_jar.xml b/.idea/artifacts/Sherly_jar.xml
deleted file mode 100644
index 139526d..0000000
--- a/.idea/artifacts/Sherly_jar.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- $PROJECT_DIR$/out/artifacts/Sherly_jar
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 7464918..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index bfa89a1..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 795a04e..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,363 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- "keyToString": {
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "SHARE_PROJECT_CONFIGURATION_FILES": "true",
- "git-widget-placeholder": "master",
- "last_opened_file_path": "/home/bly/IdeaProjects/Sherly",
- "project.structure.last.edited": "Artifacts",
- "project.structure.proportion": "0.15",
- "project.structure.side.proportion": "0.2",
- "settings.editor.selected.configurable": "preferences.pluginManager"
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1672703116568
-
-
- 1672703116568
-
-
- 1672703433480
-
-
-
- 1672703433480
-
-
- 1672703559416
-
-
-
- 1672703559416
-
-
- 1672703686539
-
-
-
- 1672703686539
-
-
- 1672703881482
-
-
-
- 1672703881482
-
-
- 1672704560597
-
-
-
- 1672704560597
-
-
- 1672749481858
-
-
-
- 1672749481858
-
-
- 1672749693035
-
-
-
- 1672749693035
-
-
- 1672749718265
-
-
-
- 1672749718265
-
-
- 1672798827144
-
-
-
- 1672798827144
-
-
- 1672874587158
-
-
-
- 1672874587158
-
-
- 1674655068301
-
-
-
- 1674655068301
-
-
- 1674655119812
-
-
-
- 1674655119812
-
-
- 1674655881410
-
-
-
- 1674655881410
-
-
- 1679341241426
-
-
-
- 1679341241426
-
-
- 1679341913990
-
-
-
- 1679341913990
-
-
- 1679341943299
-
-
-
- 1679341943299
-
-
- 1679344271798
-
-
-
- 1679344271798
-
-
- 1679344426853
-
-
-
- 1679344426853
-
-
- 1679345325362
-
-
-
- 1679345325362
-
-
- 1679346354129
-
-
-
- 1679346354129
-
-
- 1679415958151
-
-
-
- 1679415958151
-
-
- 1679508360229
-
-
-
- 1679508360229
-
-
- 1679508394699
-
-
-
- 1679508394699
-
-
- 1679508433400
-
-
-
- 1679508433400
-
-
- 1679508468115
-
-
-
- 1679508468115
-
-
- 1679688274094
-
-
-
- 1679688274094
-
-
- 1679696235787
-
-
-
- 1679696235787
-
-
- 1679698431426
-
-
-
- 1679698431426
-
-
- 1683227687665
-
-
-
- 1683227687665
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
deleted file mode 100644
index 5ee19cb..0000000
--- a/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: Main
-
diff --git a/README.md b/README.md
index 4d2eed0..79a432c 100644
--- a/README.md
+++ b/README.md
@@ -1,41 +1,39 @@
+# xxSherly
+
+A fork of [Sherly](https://github.com/BlyDoesCoding/Sherly), (not yet) using [xxHash](https://github.com/Cyan4973/xxHash).
+
+## Introduction
-# Sherly
Sherly is a Multithreaded Duplicate File Finder for your Terminal, written in java. You can Easily find duplicate Images, videos as well as any other type of Data. That can be helpful if you run on small storage or just want to keep regular housekeeping.
+## Full Usages
-## Installation
-
-Install via AUR
-
-```bash
- yay -S sherly-git
-```
-
-Compile yourself
-
-```bash
- git clone https://github.com/BlyDoesCoding/Sherly
- cd Sherly
- mkdir -p Bin
- javac -d Bin src/*.java -Xlint
- cd Bin
- jar cfe sherly.jar Main ConsoleColors.class Main.class ThreadedCompare.class
- #the jar file will be in the Bin Folder
-```
-
-
-## Usage/Examples
-
-```
+```console
Usage: sherly -f inputfolder1 inputfolder2 inputfolder3 [options]...
-
+
-h / -help show this
-f / -folder all the folders you want to scan for (see example above!)
-c / -color enable colored messages
-t / -threads override default Thread number (default is usually number of cores * 2)
-p / -progress enable progress indicator
-d / -delete delete all dups except one without asking first
- -n / -noinput skip all user input
-debug debug stuff
```
+## Build
+
+```bash
+mvn package
+```
+
+## Supported Platforms
+
+| OS | Working | Version |
+| :----: |:--------------:|:-------:|
+| Linux | Yes | 1.0 |
+| Windows 10/11/8/7 | Not yet tested | |
+| BSD | Not yet tested | |
+
+## Screenshots
+
+
diff --git a/Sherly.iml b/Sherly.iml
deleted file mode 100644
index c90834f..0000000
--- a/Sherly.iml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..bfb2be6
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,83 @@
+
+
+
+ 4.0.0
+
+ com.blydoescoding.sherly
+ xxSherly
+ 1.0
+
+ xxSherly
+
+ http://www.example.com
+
+
+ UTF-8
+ 1.7
+ 1.7
+ 11
+
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-surefire-plugin
+ 2.22.1
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+
+ com.blydoescoding.sherly.App
+
+
+
+
+
+ maven-install-plugin
+ 2.5.2
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+
+ maven-site-plugin
+ 3.7.1
+
+
+ maven-project-info-reports-plugin
+ 3.0.0
+
+
+
+
+
diff --git a/src/ConsoleColors.java b/src/ConsoleColors.java
deleted file mode 100644
index 24b2f11..0000000
--- a/src/ConsoleColors.java
+++ /dev/null
@@ -1,15 +0,0 @@
-//Just regular Colors to make it a bit prettier
-
-public class ConsoleColors {
- // Reset
- public static final String RESET = "\033[0m"; // Text Reset
-
- public static final String GREEN_BOLD = "\033[1;32m"; // GREEN
-
- public static final String BLUE_BOLD = "\033[1;34m"; // BLUE
-
- public static final String CYAN_BOLD = "\033[1;36m"; // CYAN
-
- public static final String RED_BOLD = "\033[1;31m"; // RED
-}
-
diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF
deleted file mode 100644
index 5ee19cb..0000000
--- a/src/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: Main
-
diff --git a/src/Main.java b/src/main/java/com/blydoescoding/sherly/App.java
similarity index 82%
rename from src/Main.java
rename to src/main/java/com/blydoescoding/sherly/App.java
index 52a0a7e..63a1a94 100644
--- a/src/Main.java
+++ b/src/main/java/com/blydoescoding/sherly/App.java
@@ -1,3 +1,5 @@
+package com.blydoescoding.sherly;
+
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -10,11 +12,12 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-public class Main {
+public class App {
public static int completedThreads = 0;
public static int progress = 0;
public static HashMap> fileMap = new HashMap<>();
+
public static void main(String[] args) throws InterruptedException {
boolean doTheColorThingy = false;
boolean showProgress = false;
@@ -23,13 +26,11 @@ public class Main {
boolean recordThreads = false;
int saidThreads = 0;
boolean showDebug = false;
- boolean noInput = false;
boolean help = false;
List paths = new ArrayList<>();
- for(String i : args)
- {
+ for(String i : args) {
if (recordFolder) {
if(Files.isDirectory(Paths.get(i))) {
paths.add(i);
@@ -44,7 +45,6 @@ public class Main {
if (i.equalsIgnoreCase("-f") || i.equalsIgnoreCase("-folder")) { recordFolder = true;}
if (i.equalsIgnoreCase("-t") || i.equalsIgnoreCase("-threads")) { recordThreads = true;}
if (i.equalsIgnoreCase("-d") || i.equalsIgnoreCase("-delete")) { deleteDups = true;}
- if (i.equalsIgnoreCase("-n") || i.equalsIgnoreCase("-noinput")) { noInput = true; }
if (i.equalsIgnoreCase("-h") || i.equalsIgnoreCase("-help")) { help = true;}
if (i.equalsIgnoreCase("-debug")) { showDebug = true;}
@@ -59,7 +59,6 @@ public class Main {
System.out.println(" -t / -threads override default Thread number (default is usually number of cores * 2)");
System.out.println(" -p / -progress enable progress indicator");
System.out.println(" -d / -delete delete all dups except one without asking first");
- System.out.println(" -n / -noinput skip all user input");
System.out.println(" -debug debug stuff");
return;
}
@@ -116,15 +115,16 @@ public class Main {
}
}
+
//Start Multithreading
-
//sectionedList gives the thread their Assigned Part of Files
-
ThreadedCompare threadedCompare = new ThreadedCompare(sectionedList);
threadedCompare.start();
}
+
//this updates if necessary the Progress bar and checks for Finished threads
+
while (completedThreads < availableThreads) {
TimeUnit.MILLISECONDS.sleep(250);
@@ -134,52 +134,51 @@ public class Main {
System.out.print("Progress: " + progress + " / " + filesToBeDone + " | " + (progress * 100 / filesToBeDone) + "%" + "\r");
}
}
- ArrayList toRemove = new ArrayList();
- for (String md5: fileMap.keySet()) {
- if (Main.fileMap.get(md5).size() == 1) {
- toRemove.add(md5);
+
+ ArrayList toRemove = new ArrayList();
+ for (String checksum: fileMap.keySet()) {
+ if (App.fileMap.get(checksum).size() == 1) {
+ toRemove.add(checksum);
}
}
fileMap.keySet().removeAll(toRemove);
- //now everything is finished and the Filemap (hashmap with all Dups) can be printed out in a nice view
- //System.out.println(fileMap);
+ // now everything is finished and the Filemap (hashmap with all Dups) can be printed out in a nice view
- for (String md5: fileMap.keySet()) {
+ for (String checksum: fileMap.keySet()) {
if (doTheColorThingy) {
- System.out.println(ConsoleColors.BLUE_BOLD + md5 + ConsoleColors.CYAN_BOLD + " --> " + ConsoleColors.GREEN_BOLD + fileMap.get(md5) + ConsoleColors.RESET);
+ System.out.println(ConsoleColors.BLUE_BOLD + checksum + ConsoleColors.CYAN_BOLD + " --> " + ConsoleColors.GREEN_BOLD + fileMap.get(checksum) + ConsoleColors.RESET);
} else {
- System.out.println(md5 +" --> " + fileMap.get(md5));
+ System.out.println(checksum +" --> " + fileMap.get(checksum));
}
}
- List allTheFilesWillBeDeleted = new ArrayList<>();
+ List allTheFilesWillBeDeleted = new ArrayList<>();
- long bytes = 0;
-
- for (String md5: fileMap.keySet()) {
- Main.fileMap.get(md5).remove(0);
- for (Path file: Main.fileMap.get(md5)) {
- if (file != null) {
- bytes += file.toFile().length();
- }
+ long bytes = 0;
+ for (String md5: fileMap.keySet()) {
+ App.fileMap.get(md5).remove(0);
+ for (Path file: App.fileMap.get(md5)) {
+ if (file != null) {
+ bytes += file.toFile().length();
}
- allTheFilesWillBeDeleted.addAll(Main.fileMap.get(md5));
-
}
+ allTheFilesWillBeDeleted.addAll(App.fileMap.get(md5));
+ }
- if (deleteDups) {
- delete(allTheFilesWillBeDeleted);
- } else if (!noInput) {
- ask(doTheColorThingy, bytes, allTheFilesWillBeDeleted);
- }
+ if (deleteDups) {
+ delete(allTheFilesWillBeDeleted);
+ } else {
+ ask(doTheColorThingy, bytes, allTheFilesWillBeDeleted);
+ }
}
- //print files and ask user
+
+ // print files and ask user
public static void ask(boolean color, long bytes, List deleteThem) {
if (color) {
System.out.println(ConsoleColors.RED_BOLD + (bytes / 8000000) + " unnecessary MB in " + deleteThem.size() + " Files found, do you want to Delete them? Y / N" + ConsoleColors.RESET);
@@ -193,12 +192,12 @@ public class Main {
input.close();
} else if (answer.toLowerCase().contains("n")) {
+ input.close();
return;
} else {
ask(color, bytes, deleteThem);
}
input.close();
-
}
public static void delete(List deleteThem) {
diff --git a/src/main/java/com/blydoescoding/sherly/ConsoleColors.java b/src/main/java/com/blydoescoding/sherly/ConsoleColors.java
new file mode 100644
index 0000000..cfd4c9a
--- /dev/null
+++ b/src/main/java/com/blydoescoding/sherly/ConsoleColors.java
@@ -0,0 +1,11 @@
+package com.blydoescoding.sherly;
+
+// Just regular Colors to make it a bit prettier
+
+public class ConsoleColors {
+ public static final String RESET = "\033[0m"; // Text Reset
+ public static final String GREEN_BOLD = "\033[1;32m"; // GREEN
+ public static final String BLUE_BOLD = "\033[1;34m"; // BLUE
+ public static final String CYAN_BOLD = "\033[1;36m"; // CYAN
+ public static final String RED_BOLD = "\033[1;31m"; // RED
+}
diff --git a/src/ThreadedCompare.java b/src/main/java/com/blydoescoding/sherly/ThreadedCompare.java
similarity index 55%
rename from src/ThreadedCompare.java
rename to src/main/java/com/blydoescoding/sherly/ThreadedCompare.java
index 53d1fbc..89fc090 100644
--- a/src/ThreadedCompare.java
+++ b/src/main/java/com/blydoescoding/sherly/ThreadedCompare.java
@@ -1,69 +1,69 @@
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
+package com.blydoescoding.sherly;
+
+import java.io.*;
import java.nio.file.Path;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
+
public class ThreadedCompare extends Thread {
+
private final List pathsToCompareTo;
- //private HashMap> threadFileMap = new HashMap<>();
public ThreadedCompare (List pathsToCompareTo) {
-
this.pathsToCompareTo = pathsToCompareTo;
}
@Override
public void run() {
-
for (Path file : pathsToCompareTo) {
List fileArray = new ArrayList<>();
assert fileArray != null;
fileArray.add(file);
- String MD5;
+ String checksum;
try {
- MD5 = getMD5Sum(file.toFile());
+ checksum = getChecksum(file.toFile());
} catch (IOException e) {
throw new RuntimeException(e);
}
-
- if (Main.fileMap.containsKey(MD5)) {
- fileArray.addAll(Main.fileMap.get(MD5));
- Main.fileMap.put(MD5, fileArray);
+ if (App.fileMap.containsKey(checksum)) {
+ fileArray.addAll(App.fileMap.get(checksum));
+ App.fileMap.put(checksum, fileArray);
} else {
- Main.fileMap.put(MD5, fileArray);
+ App.fileMap.put(checksum, fileArray);
}
-
- Main.progress++;
+ App.progress++;
}
-
- Main.completedThreads++;
-
+ App.completedThreads++;
}
//this is used to get the MD5 String of one of the files (one of them is just fine since they both have the same value)
- private String getMD5Sum (File file) throws IOException {
+ private String getChecksum (File file) throws IOException {
MessageDigest messageDigest = null;
+
try {
messageDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
- FileInputStream fis = new FileInputStream(file);
+
+ FileInputStream inputStream = new FileInputStream(file);
byte[] dataBytes = new byte[1024];
-
int unread = 0;
- while ((unread = fis.read(dataBytes)) != -1) {
+ while ((unread = inputStream.read(dataBytes)) != -1) {
messageDigest.update(dataBytes, 0, unread);
}
- byte[] mdbytes = messageDigest.digest();
- StringBuilder sb = new StringBuilder();
- for (byte mdbyte : mdbytes) {
- sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
+
+ inputStream.close();
+
+ // get digest & create hexadecimal represenation
+ byte[] digestBytes = messageDigest.digest();
+ StringBuilder stringBuilder = new StringBuilder();
+ for (byte digestByte : digestBytes) {
+ stringBuilder.append(Integer.toString((digestByte & 0xff) + 0x100, 16).substring(1));
}
- return sb.toString();
+ return stringBuilder.toString();
}
}
diff --git a/src/sherly b/src/sherly
deleted file mode 100644
index 1ffa2b8..0000000
--- a/src/sherly
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/sh
-java -jar /usr/share/java/sherly/sherly.jar $@