Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (29 sloc) 826 Bytes
#!/usr/bin/python
class dFile:
def __init__(self, name, data, parent):
self.name = name
self.data = data
self.size = len(data)
self.perms = 644
self.parent = parent
def read(self):
return self.data
def getSize(self):
return str(self.size)+'B' if self.size<1024 else str(round(self.size/1024.0,1))+'KB'
def printf(self):
print self.name+" ",
def printl(self):
print "-%s%s%s\t%s\t%s"%('rw-', 'rw-', 'r--', self.getSize(), self.name)
def remove(self):
self.parent.files.remove(self)
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=='.':
return self
elif path=='..':
return None if self.parent is None else self.parent.traverse(paths, drive)
else:
return None