package exo2.fileSystem;

import exo2.files.Directory;
import exo2.files.File;

public class FileSystem {
	private Node root, wd;
	public FileSystem(Node root) {
		this.root = root;
		this.wd = root;
	}
	public Node getRoot() {
		return root;
	}
	public Node getWD() {
		return wd;
	}

	public Node getFile(String name) {
		return wd.getFile(name);
	}
	
	public boolean touch(String name) {
		if (wd.getFile(name) != null)
			return false;
		Node f = new File(name);
		wd.add(f);
		return true;
	}
	
	public boolean mkdir(String name) {
		if (wd.getFile(name) != null)
			return false;
		Node d = new Directory(name);
		wd.add(d);
		return true;
	}
}
