-
Notifications
You must be signed in to change notification settings - Fork 4
/
CurrentDir.java
37 lines (34 loc) · 946 Bytes
/
CurrentDir.java
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
/**
* A class that represents the current working directory of the shell.
* @author michaelroytman
*/
public class CurrentDir {
private String currentDir; //String representing current working directory path
/**
* Constructor; sets initial directory to where shell class is located.
*/
public CurrentDir() {
currentDir = System.getProperty("user.dir");
}
/**
* Getter method for current working directory.
* @return
*/
public String getDir() {
return currentDir;
}
/**
* Setter method for current working directory.
* @param destination destination of new working directory
* @param append if append is true, destination is added on to current working
* directory; if append is false, current working directory is set to destination.
*/
public void setDir(String destination, Boolean append) {
if (append) {
currentDir = currentDir + destination;
}
else {
currentDir = destination;
}
}
}