public override void Execute(IOutputter outputter) { bool retVal = false; // cd without parameters if (newDirectoryName == null) { outputter.PrintLine(Drive.CurrentDirectory.Path); return; } // cd with parameters: Check if passed directory is valid before change to this directory FileSystemItem newDir = Drive.GetItemFromPath(newDirectoryName); if (newDir == null) { outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED); return; } if (newDir.IsDirectory() == false) { outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED); return; } if (Drive.GetItemFromPath(newDir.Path) != newDir) { outputter.PrintLine("Path not in drive " + Drive.DriveName); return; } if (newDir.IsDirectory()) { retVal = Drive.ChangeCurrentDirectory((Directory)newDir); } if (retVal == false) { outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED); } }