MCPcopy Create free account
hub / github.com/RetiredWizard/PyDOS / chkPath

Function chkPath

sdmount.py:32–72  ·  view source on GitHub ↗
(tstPath)

Source from the content-addressed store, hash-verified

30def sdMount(drive,spiNo):
31
32 def chkPath(tstPath):
33 validPath = True
34
35 simpPath = ""
36 if tstPath == []:
37 validPath = True
38 simpPath = ""
39 else:
40
41 savDir = os.getcwd()
42
43 for path in tstPath:
44 if path == "":
45 os.chdir("/")
46
47 elif os.getcwd() == "/" and path == "..":
48 validPath = False
49 break
50
51 elif path == ".":
52 continue
53
54 elif path == ".." and len(os.getcwd().split('/')) == 2:
55 os.chdir('/')
56
57 elif path == "..":
58 os.chdir("..")
59
60 elif path in os.listdir() and (os.stat(path)[0] & (2**15) == 0):
61 os.chdir(path)
62
63 else:
64 validPath = False
65 simpPath = ""
66 break
67
68 if validPath:
69 simpPath = os.getcwd()
70 os.chdir(savDir)
71
72 return((validPath,simpPath))
73
74 def absolutePath(argPath,currDir):
75

Callers 1

sdMountFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected