private void dl(Command c) { if (c.getArgs() == null || c.getArgs().Length != 2) { Console.WriteLine("Usage: dl <remote file> <local file>"); } else { string remote = c.getArgs()[0].Replace(" ", "%20"); string local = c.getArgs()[1]; Console.WriteLine("Downloading " + remote + " to " + local); ftp.download(remote, local); //Console.WriteLine("I'd download that file if I was implemented yet."); } }
private void ls(Command c) { if (c.getArgs() == null || c.getArgs().Length != 1) { Console.WriteLine("Usage: ls <directory path>"); } else { Console.WriteLine(c.getArgs()[0]); Console.WriteLine( ftp.pwdSimple(c.getArgs()[0]) ); } }
private void ul(Command c) { if (c.getArgs() == null || c.getArgs().Length != 2) { Console.WriteLine("Usage: ul <local file> <remote file>"); } else { Console.WriteLine("I'd upload that file if I was implemented yet."); } }
private void autodl(Command c) { Console.WriteLine("Oh God, that's not even close to done yet."); }
private void rm(Command c) { if(c.getArgs() == null || c.getArgs().Length != 1) { Console.WriteLine("Usage: rm <remote file>"); } else { Console.WriteLine("I'd remove that file if I was implemented yet."); } }
private bool quit(Command c) { if (c.getArgs() != null) { Console.WriteLine("Quit what?"); return false; } return true; }
private bool processCommand(Command command) { bool end = false; if (command.isUnknown()) { Console.WriteLine("Do what now?"); return false; } string commandWord = command.getCommand(); switch (commandWord) { case "ls": ls(command); break; case "lsd": lsd(command); break; case "help": help(); break; case "quit": end = quit(command); break; case "dl": dl(command); break; case "ul": ul(command); break; case "rm": rm(command); break; case "mkdir": mkdir(command); break; case "mv": mv(command); break; case "autodl": autodl(command); break; case "cls": cls(); break; default: Console.WriteLine("Do what now?"); break; } return end; }
private void mv(Command c) { if (c.getArgs() == null || c.getArgs().Length != 2) { Console.WriteLine("Usage: mv <old filename> <new filename>"); } else { Console.WriteLine("I'd rename that file if I was implemented yet."); } }
private void mkdir(Command c) { if(c.getArgs() == null || c.getArgs().Length != 1) { Console.WriteLine("Usage: mkdir <remote directory>"); } else { Console.WriteLine("I'd make that directory if I was implemented yet."); } }