9 self
.allowed_prefix
= [
12 '/mnt/kesunka/serialy',
15 self
.back_item
= '__back__'
16 self
.cpath
= self
.allowed_prefix
[0]
19 return self
.allowed_prefix
21 def getCurrentPath(self
):
24 def getFile(self
, filename
):
25 out
= self
.cpath
+ "/" + filename
26 if self
.checkPath(out
):
30 def setPath(self
, dir):
31 if self
.checkPath(dir):
34 def checkPath(self
, file):
35 if re
.match("("+string
.join(self
.allowed_prefix
, "|")+")", file) and not re
.search("(/\.\.|\.\./)", file):
40 def goBack(self
, item
=None):
42 if item
.split('/')[-1] == self
.back_item
:
43 print "matches ", self
.back_item
44 out
= self
.cpath
[:self
.cpath
.rfind('/')]
45 if re
.match("("+string
.join(self
.allowed_prefix
, "|")+")", out
):
49 out
= self
.transformList(os
.listdir(self
.cpath
))
52 def transformList(self
, list):
56 if all(ord(c
) < 128 for c
in d
):
58 out
.insert(0, self
.back_item
)
62 if __name__
== "__main__":
64 print fc
.getFile("na/..me")