예제 #1
0
        public static void Dir()
        {
            Console.Write("Directory listing of " + Directory.GetCurrentDirectory() + "\n\n");

            if (DirectoryOperations.directoryIsEmpty(Directory.GetCurrentDirectory()))
            {
                Console.WriteLine("This directory is empty.");
                return;
            }
            string[] directories = GetDirectories(Directory.GetCurrentDirectory());
            string[] files       = GetFiles(Directory.GetCurrentDirectory());

            if (directories[0] != "$")
            {
                for (int i = 0; i < directories.Length; i++)
                {
                    Console.Write("[" + directories[i] + "]\n");
                }
            }
            if (files[0] != "$")
            {
                for (int i = 0; i < files.Length; i++)
                {
                    Console.Write(files[i] + "\n");
                }
            }
        }
예제 #2
0
        protected override void Run()
        {
            // Command prompt
            Console.Write("\n" + Directory.GetCurrentDirectory() + "> ");
            var input = Console.ReadLine();

            // Split the input into an array
            string[] preparse = parseCommand(input);

            // Take the command out of the array and put it into the final arguments array. Convert the List into an array. We now have our arguments!
            string command = preparse[0];

            string[] arguments = new string[preparse.Length - 1];
            for (int i = 0; i < arguments.Length; i++)
            {
                arguments[i] = preparse[i + 1];
            }

            // If command == <command> do command
            if (command == "beep")
            {
                Beep(arguments);
            }
            else if (command == "command")
            {
                Command();
            }
            else if (command == "cls")
            {
                Console.Clear();
            }
            else if (command == "help")
            {
                Help(arguments);
            }
            else if (command == "dir")
            {
                DirectoryListing.Dir();
            }
            else if (command == "drivelist")
            {
                Drives.Drivelist();
            }
            else if (command == "cd")
            {
                DirectoryOperations.Cd(arguments);
            }
            else if (command == "checktime")
            {
                CheckTime();
            }
            else if (command == "calculate")
            {
                Calculator.Calculate(arguments);
            }
            else if (command == "shutdown")
            {
                Console.Write("Goodbye!\n");
                Console.Beep(1975, 200);
                Console.Beep(1318, 200);
                Console.Beep(880, 200);
                Console.Beep(987, 300);
                PowerOperations.Shutdown(arguments);
            }
            else if (command == "kitty")
            {
                Kitty.kitty(arguments);
            }
            else if (command == "rm")
            {
                FileOperations.removeFile(arguments);
            }
            else if (command == "rmdir")
            {
                DirectoryOperations.removeDirectory(arguments);
            }
            else if (command == "mkdir")
            {
                DirectoryOperations.createDirectory(arguments);
            }
            else if (command == "copy")
            {
                FileOperations.copyFile(arguments);
            }
            else if (command == "move")
            {
                FileOperations.moveFile(arguments);
            }
            else if (command == "initgui")
            {
                DesktopEnvironment.InitGUI(arguments);
            }
            else // Else, say it's a bad command.
            {
                Console.Write("Bad command.\n");
            }
        }