class ChrootFileSystem(FileSystem):
'''ChrootFileSystem(fs, path) exposes a FileSystem whose root is |path| inside
- |fs|, so ChrootFileSystem(fs, '/hello').Read(['/world']) is equivalent to
- fs.Read(['/hello/world']) with the '/hello' prefix stripped from the result.
+ |fs|, so ChrootFileSystem(fs, 'hello').Read(['world']) is equivalent to
+ fs.Read(['hello/world']) with the 'hello' prefix stripped from the result.
'''
def __init__(self, file_system, root):
self._file_system = file_system
self._root = root.strip('/')
- def Read(self, paths, binary=False):
+ def Read(self, paths):
# Maintain reverse mapping so the result can be mapped to the original
# paths given (the result from |file_system| will include |root| in the
# result, which would be wrong).
prefixed_paths[prefixed] = path
return prefixed
future_result = self._file_system.Read(
- tuple(prefix(path) for path in paths), binary=binary)
+ tuple(prefix(path) for path in paths))
def resolve():
return dict((prefixed_paths[path], content)
for path, content in future_result.Get().iteritems())
return Future(delegate=Gettable(resolve))
+ def Refresh(self):
+ return self._file_system.Refresh()
+
def Stat(self, path):
return self._file_system.Stat(posixpath.join(self._root, path))
def GetIdentity(self):
return StringIdentity(
'%s/%s' % (self._file_system.GetIdentity(), self._root))
+
+ def __repr__(self):
+ return 'ChrootFileSystem(%s, %s)' % (
+ self._root, repr(self._file_system))