-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMkDirCommand.java
More file actions
25 lines (22 loc) · 783 Bytes
/
MkDirCommand.java
File metadata and controls
25 lines (22 loc) · 783 Bytes
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
package IO;
import java.io.File;
public class MkDirCommand extends Command {
public MkDirCommand() {
super("mkdir");
}
@Override
public void action(String[] cmd) {
if (cmd.length > 1) {
File newDir = new File(Main.wd, cmd[1]);
if (!newDir.exists()) {
boolean created = newDir.mkdir();
if (created) {
System.out.println("Dir succesfully created.");
} else
System.out.println("Failed o create Dir.");
} else
System.out.println("Dir with name " + cmd[1] + " already exsits.");
} else
System.out.println("No file specified. (example: mkdir mydir) -> makes a mydir named directory.");
}
}