-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcdCommand.java
More file actions
63 lines (53 loc) · 1.66 KB
/
cdCommand.java
File metadata and controls
63 lines (53 loc) · 1.66 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
package com.company;
//import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.NotNull;
import java.nio.file.Path;
import java.nio.file.Paths;
/** done with the short path and long path
* handle the cd .. done
*
*/
public class cdCommand extends Command {
cdCommand(@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);
}
cdCommand(@NotNull String [] _args , Path _path){
args = new String[_args.length];
for (int i = 0 ; i <args.length ; ++i )
args[i] = _args[i];
// mPath = _path;
TerminalPath = _path;
myPath = _path;
}
public boolean check(){/// todo
return DirectoryExist(myPath) && args.length==1;
}
public void run(String _path){ /// todo redundant path
args[0] = toAbsolutePath(args[0]);
myPath = Paths.get(args[0]);
TerminalPath = Paths.get(_path);
if(!check()){///todo cout warning
/// if error return my path to the terminal path
myPath = TerminalPath;
}
// if(p.toFile().isDirectory()){
// mPath = args[0];
// }
// else {
// mPath = _path + '/' + args[0];
// }
//TODO: Handle wring number of arguments
return;
}
public String changeDirectory(){
this.run(TerminalPath.toString());
// return this.mPath;
return myPath.toString();
}
public void ShowArguments(){/// todo
}
}