Created
December 4, 2016 22:40
-
-
Save Glamhoth/597bf49bc2e641fb342298239ac55dd4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef COMMANDS_H_INCLUDED | |
#define COMMANDS_H_INCLUDED | |
void mainDir(std::string); | |
void makeReady(); | |
void welcomeLogin(); | |
std::string currLoc ("home"); | |
std::string prevLoc (""); | |
void commandExecute(std::string command) | |
{ | |
if (command == "exit") | |
{ | |
std::cout << "TURNING OFF..." << std::endl; | |
exit(0); | |
} | |
else if (command == "logout") | |
{ | |
system("CLS"); | |
currLoc = "home"; | |
prevLoc = ""; | |
welcomeLogin(); | |
} | |
else if (command == "dir") | |
{ | |
mainDir(currLoc); | |
} | |
else if (command == "cd:A") | |
{ | |
if (currLoc == "home") | |
{ | |
prevLoc = "home"; | |
currLoc = ("A:"); | |
makeReady(); | |
} | |
else | |
{ | |
std::cout << "Directory doesn't exist." << std::endl; | |
makeReady(); | |
} | |
} | |
else if (command == "cd") | |
{ | |
currLoc = ("home"); | |
makeReady(); | |
} | |
else if (command == "cd:") | |
{ | |
if (prevLoc == "home") | |
{ | |
currLoc = ("home"); | |
makeReady(); | |
} | |
else | |
{ | |
commandExecute(prevLoc); | |
} | |
} | |
else | |
{ | |
std::cout << "Wrong command." << std::endl; | |
makeReady(); | |
} | |
} | |
#endif // COMMANDS_H_INCLUDED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment