MCPcopy Index your code
hub / github.com/RetiredWizard/PyDOS / prDir

Function prDir

PyDOS.py:332–387  ·  view source on GitHub ↗
(dirPath,swBits)

Source from the content-addressed store, hash-verified

330 return (nLines,nFiles,tFSize,nDirs,quit)
331
332 def prDir(dirPath,swBits):
333 if swBits & (swAllB-int('010110',2)):
334 print("Illegal switch, Command Format: DIR[/p][/w][/s] [path][file]")
335 return
336
337 savDir = os.getcwd()
338 fullPath = absolutePath(dirPath,savDir)
339
340 pathDirs = fullPath.split(sep)
341 lastDir = pathDirs.pop(-1)
342
343 (validPath, tmpDir) = chkPath(pathDirs)
344
345 if validPath:
346
347 os.chdir(tmpDir)
348
349 if tmpDir == sep:
350 pathDirs = [""]
351 else:
352 pathDirs = tmpDir.split(sep)
353
354 # Check for relative directory from possible mount point root
355 if len(pathDirs) == 2:
356 if lastDir == ".":
357 os.chdir(sep)
358 lastDir = tmpDir[1:]
359 elif lastDir == "..":
360 os.chdir(sep)
361 lastDir = ""
362
363 tmpDir = os.getcwd()
364
365 if lastDir in os.listdir() or lastDir in ".." or "*" in lastDir or "?" in lastDir or \
366 swBits & int('000010',2):
367
368 if lastDir in os.listdir():
369 if aFile(pFmt(lastDir,False)):
370 isFile = True
371 else:
372 isFile = False
373 else:
374 if lastDir in ".." or (tmpDir == sep and lastDir == ""):
375 isFile = False
376 else:
377 isFile = True
378
379 dirLoop(tmpDir,lastDir,isFile,bool(swBits&int('000100',2)),bool(swBits&int('010000',2)),bool(swBits&int('000010',2)),True)
380 else:
381 print("File",dirPath,"not found. (1)")
382
383 os.chdir(savDir)
384 else:
385 print("File",dirPath,"not found. (2)")
386
387 return
388
389 def filecpy(file1,file2):

Callers 1

PyDOSFunction · 0.85

Calls 4

dirLoopFunction · 0.85
absolutePathFunction · 0.70
chkPathFunction · 0.70
pFmtFunction · 0.70

Tested by

no test coverage detected