-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.java
More file actions
executable file
·114 lines (97 loc) · 3.05 KB
/
test.java
File metadata and controls
executable file
·114 lines (97 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import java.util.ArrayList;
import java.io.*;
public class test {
private static String readln() {
String ln = "";
try {
BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
ln = is.readLine();
// if (ln.length() == 0 ) return null;
} catch (IOException e) {
System.out.println("IOException: " + e);
}
return ln;
}
public static void print(ArrayList<ArrayList<File>> duplicatelist)
{
for (ArrayList<File> al : duplicatelist)
{
boolean first = true;
for (File fl : al)
{
if(!first)
System.out.print(" : ");
first=false;
try {
System.out.print(fl.getCanonicalPath());
} catch (Exception e) {
System.out.print("*ERROR*");
}
}
System.out.println("");
}
}
public static void main(String[] args) {
try {
Rulelist rulelist = new Rulelist();
final Filelist fl = new Filelist(".");
System.out.println("-- SCAN --");
// start this in thread
new Thread(new Runnable() {
@Override
public void run() {
fl.filescan();
}
}).start();
// loop progress...
while (!fl.getScanCompleted()) {
try {
System.out.println("scanning... " + fl.getScanRemain());
Thread.sleep(1000);
} catch (InterruptedException ie) { ; }
}
int totalfiles = fl.countfiles();
System.out.println("Files to Compare: " + totalfiles);
System.out.println("-- COMPARE --");
// start this in thread
new Thread(new Runnable() {
@Override
public void run() {
fl.filecompare();
}
}).start();
// loop progress...
while (!fl.getCompareCompleted()) {
try {
System.out.println("comparing... " + fl.getProcessed() + "/" + totalfiles + " " + fl.getMatches());
Thread.sleep(1000);
} catch (InterruptedException ie) { ; }
}
// fl.print();
ArrayList<ArrayList<File>> allList = fl.getDuplicatelist();
ArrayList<ArrayList<File>> currentList = allList;
while (true) {
print(currentList);
System.out.print("> ");
String argument = readln();
// going to need a command parser class...
String[] arguments = argument.split(":");
if (arguments.length == 3) {
if ("group".equals(arguments[0]))
{
currentList = rulelist.evalGroup(currentList, arguments[1],arguments[2]);
} else if ("filter".equals(arguments[0])) {
// remember to check that we're not deleting all duplicates
currentList = rulelist.evalFilter(currentList, arguments[1], arguments[2]);
} else {
rulelist.printHelp();
}
} else {
rulelist.printHelp();
}
}
} catch (Exception e) {
System.out.println ("An error occurred: " + e );
}
}
}