-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
114 lines (94 loc) · 3.83 KB
/
Main.java
File metadata and controls
114 lines (94 loc) · 3.83 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.Scanner;
public class Main {
public static void main(String[] args) {
MyFile.help();
Scanner in = new Scanner(System.in);
String[] str = new String[3];
int index;
boolean exit = false;
do {
System.out.print("> ");
index = 0;
for (String line : in.nextLine().replaceAll(" ", "\n").lines().toList()) {
if (line.length() == 0) {
} else {
if (index <= 2) {
str[index] = line;
}
index++;
}
}
if (!(str[0] == null)) {
try {
switch (str[0]) {
case "ls":
MyFile.listDirectory(str[1]);
break;
case "ls_py":
MyFile.listPythonFiles(str[1]);
break;
case "is_dir":
MyFile.isDirectory(str[1]);
break;
case "define":
MyFile.define(str[1]);
break;
case "readmod":
MyFile.printPermissions(str[1]);
break;
case "setmod":
MyFile.setPermissions(str[1], str[2]);
break;
case "cat":
MyFile.printContent(str[1]);
break;
case "append":
MyFile.appendFooter(str[1]);
break;
case "bc":
MyFile.createBackup(str[1]);
break;
case "greplong":
MyFile.printLongestWord(str[1]);
break;
case "help":
MyFile.help();
break;
case "exit":
MyFile.exit();
exit = true;
break;
default:
System.out.println("Нет такой команды для отображения списка. Введите команду help");
}
} catch (Exception e) {
if (str[0].equals("setmod")){
try {
if (!str[1].isEmpty()) {
System.out.println(str[0] + " " + str[1] + """
<perm пусто> или неверный Ввод
Для корректного ввода примеры ниже:
rwx : полный доступ Read Write Execute;
r-- : только Read;
-w- : только Write;
--x : только Execute;
--- : полный запрет Read Write Execute;
rw- , r-x итд.
""");
}
}catch (Exception a){
System.out.println(a);
System.out.println(str[0] + " <path пусто>");
}
}else {
System.out.println(e);
System.out.println(str[0] + " <path пусто>");
}
}
}
for (int i = 0; i < str.length; i++) {
str[i] = null;
}
} while (!exit);
}
}