add cd functionality
This commit is contained in:
parent
c85a3d6793
commit
6425a3f20b
21
main.py
21
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: ")
|
||||
|
|
Loading…
Reference in New Issue
Block a user