-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHashPath.java
More file actions
38 lines (38 loc) · 1.23 KB
/
Copy pathHashPath.java
File metadata and controls
38 lines (38 loc) · 1.23 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
import java.io.*;
public class HashPath {
public static String execIn(ProcessBuilder pb) throws Exception {
Process p = pb.start();
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String l=in.readLine();
in.close();
return l;
}
public static String execIn(String c0,String c1) throws Exception {
return execIn(new ProcessBuilder(c0,c1));
}
public static String execIn(String c0,String c1,String c2) throws Exception {
return execIn(new ProcessBuilder(c0,c1,c2));
}
public static String execIn(String c0,String c1,String c2,String c3) throws Exception {
return execIn(new ProcessBuilder(c0,c1,c2,c3));
}
public static void main(String[] a) throws Exception {
LineNumberReader lnr = new LineNumberReader(new InputStreamReader(System.in));
String f;
String ls="";
while((f=lnr.readLine())!=null) {
if (OS.isWindows()) {
String e="4867ccab1c36f33dec005e83eef8dfb6d3b166941a72400aa3c963675c2a7dae.exe";
ls=execIn("G:/SpaceDrive/1220"+e,f).substring(1); // skip trailing "\"
} else if (OS.isMac()) {
ls=execIn("shasum","-a","256",f);
} else if (OS.isUnix()) {
ls=execIn("sha256sum",f);
} else {
//???
}
System.out.println(ls.split(" ")[0]+" "+f);
}
}
}