Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (32 sloc) 779 Bytes
write = True if '>' in args else False
if write: args.remove('>')
argsLen = len(args)
if argsLen==2:
args[1] = args[1][:-1] if args[1][-1]=='/' else args[1]
tmp = folder.traverse(list(reversed(args[1].split('/')[:-1])), drive)
if isinstance(tmp,dFolder):
new = args[1].split('/')[-1]
f = tmp.find(new)
if write:
if f is None:
data = []
eof = False
while not eof:
try:
data.append(raw_input())
except EOFError:
eof = True
except Exception as ex:
raise ex
tmp.addFile(dFile(new, "\n".join(data), tmp))
else:
print "%s: cannot write an already written file"%(args[1])
else:
if isinstance(f, dFile):
print f.read()
else:
print "%s: no such file"%(args[1])
else:
nfd(args[1])
else:
cnu(args[0])