package net.morilib.sh;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Collection;

public class ShFileSystemStub2 implements ShFileSystem {

	static class Fl1 implements ShFile {

		ShFile root;
		String name;

		Fl1(ShFile r, String s) {
			root = r;
			name = s;
		}

		public Collection<ShFile> getFiles() {
			return Arrays.asList(new ShFile[] {
					new Fl1(this, "***"),
					new Fl1(this, "[a-z]"),
					new Fl1(this, "???"),
			});
		}

		public String getName() {
			return name;
		}

		public boolean isDirectory() {
			return true;
		}

		public boolean isExecutable() {
			return false;
		}

		public String toRealPath() {
			return toString();
		}

		public String toString() {
			if(root == null) {
				return "";
			} else {
				return root.toString() + "/" + name;
			}
		}

		public boolean isExist() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isFile() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isReadable() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isWritable() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isHidden() {
			return name.length() > 0 && name.startsWith(".");
		}

		public boolean isNewerThan(ShFile f) {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isOlderThan(ShFile f) {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isZeroFile() {
			// TODO Auto-generated method stub
			return false;
		}

		public InputStream getInputStream() {
			// TODO Auto-generated method stub
			return null;
		}

		public PrintStream getPrintStream(boolean append) {
			// TODO Auto-generated method stub
			return null;
		}

		public ShProcess getProcess(String... args) {
			// TODO Auto-generated method stub
			return null;
		}

		public long getLastModified() {
			// TODO Auto-generated method stub
			return 0;
		}

		public ShFile toAbsolute() {
			// TODO Auto-generated method stub
			return null;
		}

		public boolean mkdir() {
			return true;
		}

		public boolean renameTo(ShFile f) {
			if(f instanceof Fl1) {
				root = ((Fl1)f).root;
				name = ((Fl1)f).name;
				return true;
			} else {
				return false;
			}
		}

		public void setLastModified(long time) {
		}

		public boolean rmdir() {
			return false;
		}

		public boolean deleteFile() {
			return false;
		}

		public ShStat getStat() {
			return new ShStat();
		}

	}

	static class Fl2 implements ShFile {

		ShFile root;
		String name;

		Fl2(ShFile r, String s) {
			root = r;
			name = s;
		}

		public Collection<ShFile> getFiles() {
			return Arrays.asList(new ShFile[] {
					new Fl2(this, "takane"),
					new Fl2(this, "hibiki"),
					new Fl2(this, "miki"),
					new Fl2(this, "yayoi"),
			});
		}

		public String getName() {
			return name;
		}

		public boolean isDirectory() {
			return true;
		}

		public boolean isExecutable() {
			return false;
		}

		public String toRealPath() {
			return toString();
		}

		public String toString() {
			if(root == null) {
				return "";
			} else {
				return root.toString() + "/" + name;
			}
		}

		public boolean isExist() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isFile() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isReadable() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isWritable() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isHidden() {
			return name.length() > 0 && name.startsWith(".");
		}

		public boolean isNewerThan(ShFile f) {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isOlderThan(ShFile f) {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isZeroFile() {
			// TODO Auto-generated method stub
			return false;
		}

		public InputStream getInputStream() {
			// TODO Auto-generated method stub
			return null;
		}

		public PrintStream getPrintStream(boolean append) {
			// TODO Auto-generated method stub
			return null;
		}

		public ShProcess getProcess(String... args) {
			// TODO Auto-generated method stub
			return null;
		}

		public long getLastModified() {
			// TODO Auto-generated method stub
			return 0;
		}

		public ShFile toAbsolute() {
			// TODO Auto-generated method stub
			return null;
		}

		public boolean mkdir() {
			return true;
		}

		public boolean renameTo(ShFile f) {
			if(f instanceof Fl1) {
				root = ((Fl1)f).root;
				name = ((Fl1)f).name;
				return true;
			} else {
				return false;
			}
		}

		public void setLastModified(long time) {
		}

		public boolean rmdir() {
			return false;
		}

		public boolean deleteFile() {
			return false;
		}

		public ShStat getStat() {
			return new ShStat();
		}

	}

	public ShFile getCurrentDirectory() {
		return new Fl2(null, "/");
	}

	public ShFile getRoot() {
		return new Fl1(null, "");
	}

	public ShFile getFile(String s) {
		if(s.equals("/kotori")) {
			return new Fl1(null, "/kotori");
		} else {
			return null;
		}
	}

	public ShFile getFile(String dir, String name) {
		// TODO Auto-generated method stub
		return null;
	}

	public ShFile getFile(ShFile dir, String name) {
		// TODO Auto-generated method stub
		return null;
	}

	public void setCurrentDirectory(ShFile s) {
		// TODO Auto-generated method stub
		
	}

	public ShSecurityPolicy getSecurityPolicy() {
		return ShSecurityPolicy.ALL_PERMITTED;
	}

	public ShFile getHome() {
		return getFile("/");
	}

	public InputStream getProfile() {
		return null;
	}

	public InputStream getRc() {
		return null;
	}

}
