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

Function sdMount

sdmount.py:30–207  ·  view source on GitHub ↗
(drive,spiNo)

Source from the content-addressed store, hash-verified

28 import storage
29
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
76 if argPath[0] == '/':
77 fullPath = argPath
78 elif currDir == '/':
79 fullPath = '/'+argPath
80 else:
81 fullPath = currDir+'/'+argPath
82
83 if len(fullPath) > 1 and fullPath[-1] == '/':
84 fullPath = fullPath[:-1]
85
86 return(fullPath)
87

Callers 1

sdmount.pyFile · 0.85

Calls 3

do_mountFunction · 0.85
absolutePathFunction · 0.70
chkPathFunction · 0.70

Tested by

no test coverage detected