-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.php
52 lines (46 loc) · 1.11 KB
/
main.php
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
<?php //main.php
//File deduper
//Requires
require_once("filer.php");
//Main function
function main(string $cd = ""){
$stdin = fopen("php://stdin", "r");
$invalid_uin = "Invalid input. After debugging, this will restart loop.\n";
$out = array("err" => 0, "msg" => "");
if(empty($cd)){
$cd = getcwd() . "/";
}
//Prompt
print("Do you wish to dedupe the current directory: \"{$cd}\"? [y/n]");
//Get input
switch($in = strtolower(trim(fgets($stdin)))){
case empty($in) == TRUE:
case $in == "":
case $in == "\n":
print($invalid_uin);
return 1; //Error
break;
case $in == "yes":
case $in == "y":
print("Preparing to dedupe...\n");
$out = Dedupe\Filer\scan($cd);
if($out["err"] != 0){
print("ERROR DEDUPING: " . $out["msg"] . "\n");
return 1;
}
break;
case $in == "no":
case $in == "n":
print("Ok, canceled. Exiting.\n");
return 0;
break;
default:
print($invalid_uin);
return 1; //Error
break;
}
printf("Finished checking for duplicates!\n\t%s\n", $out["msg"]);
return 0;
}
main(); //Run main loop
?>