diff --git a/main.py b/main.py index 5cab815..524d84f 100755 --- a/main.py +++ b/main.py @@ -19,6 +19,27 @@ try: print(currentDirectory) if command == "exit": exit() + if command == "cd": + try: + cdDirectory = input("Directory: ") + if cdDirectory[0] == "/": + if os.path.isdir(cdDirectory) == False: + if os.path.isfile(cdDirectory) == True: + print("That's not a directory, that's a file!") + else: + print("That directory doesn't exist.") + else: + currentDirectory = cdDirectory + else: + if os.path.isdir(currentDirectory + cdDirectory) == False: + if os.path.isfile(currentDirectory + cdDirectory) == True: + print("That's not a directory, that's a file!") + else: + print("That directory doesn't exist.") + else: + currentDirectory = cdDirectory + except Exception: + print("Either there was an error or that file doesn't exist.") elif command == ("cat"): try: catFile = input("File to catalog: ")