-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrmCommand.java
More file actions
46 lines (41 loc) · 1.24 KB
/
rmCommand.java
File metadata and controls
46 lines (41 loc) · 1.24 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
package com.company;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
public class rmCommand extends Command {
rmCommand(@NotNull String [] _args , String _path) {
args = new String[_args.length];
for (int i = 0 ; i <args.length ; ++i )
args[i] = _args[i];
TerminalPath = Paths.get(_path);
myPath = Paths.get(_path);
}
rmCommand(@NotNull String [] _args , Path _path){
args = new String[_args.length];
for (int i = 0 ; i <args.length ; ++i )
args[i] = _args[i];
TerminalPath = _path;
myPath = _path;
}
protected boolean check() {
return DirectoryExist(myPath) && args.length==1;
}
protected void run(String path) {
args[0]= toAbsolutePath(args[0]);
File file = new File(args[0]);
TerminalPath = Paths.get(path);
if(check() && file.isFile()){
file.delete();
}
else if (file.isDirectory()){
System.out.println("Error : is a Directory");
}
else{
System.out.println("Error too much arguments");
}
}
protected void ShowArguments() {
///todo
}
}