Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (51 sloc) 1.54 KB
from dFile import dFile
class dFolder:
def __init__(self, name, parent): = name
self.files = []
self.folders = []
self.perms = 755
self.parent = parent
def add(self, f):
self.addFile(f) if isinstance(f,dFile) else self.addFolder(f)
def addFile(self, f):
def addFolder(self, f):
def empty(self):
return len(self.folders)==0 and len(self.files)==0
def getFiles(self):
return sorted(self.files, key=lambda x:
def getFolders(self):
return sorted(self.folders, key=lambda x:
def getAll(self):
return sorted(self.files+self.folders, key=lambda x:
def getName(self):
return 'root' if'' else
def find(self, name):
f = filter(lambda x:, (self.files+self.folders))
return None if len(f)==0 else f[0]
def printf(self):
print"/ ",
def printl(self):
print "d%s%s%s\t4KB\t%s"%('rwx','r-x','r-x',
def remove(self):
if self.parent is not None:
print "cannot delete hard drive"
def to_s(self, line):
self.printl() if line else self.printf()
def traverse(self, paths, drive=None):
if len(paths)==0: return self
path = paths.pop()
if path=='' and drive is not None:
return drive.traverse(paths)
elif path=='.':
return self.traverse(paths)
elif path=='..':
return None if self.parent is None else self.parent.traverse(paths)
tmp = self.find(path)
return None if tmp is None else tmp.traverse(paths)
Jump to Line
Something went wrong with that request. Please try again.