def seek(self, offset): if self._file is None: raise FileClosedError("File closed") try: self._file.seek(offset, SEEK_SET) except IOError, e: cls = self._errorLookup.get(e[0], FileError) raise cls("Failed to seek in file '%s': %s" % (self._path, str(e)))
def tell(self): if self._file is None: raise FileClosedError("File closed") try: return self._file.tell() except IOError, e: cls = self._errorLookup.get(e[0], FileError) raise cls("Failed to tell position in file '%s': %s" % (self._path, str(e)))
def read(self, size): if self._file is None: raise FileClosedError("File closed") try: data = self._file.read(size) return defer.succeed(data) except IOError, e: cls = self._errorLookup.get(e[0], FileError) return defer.fail( cls("Failed to read data from %s: %s" % (self._path, str(e))))
def read(self, size): if self._delegate is None: raise FileClosedError("File closed") try: d = self._delegate.read(size, self.stats) if isinstance(d, defer.Deferred): return d return defer.succeed(d) except IOError, e: cls = errnoLookup.get(e.errno, FileError) return defer.fail(cls("Failed to read cached data: %s", str(e)))
def seek(self, offset): if self._delegate is None: raise FileClosedError("File closed") return self._delegate.seek(offset)
def tell(self): if self._delegate is None: raise FileClosedError("File closed") return self._delegate.tell()
def getsize(self): if self._delegate is None: raise FileClosedError("File closed") return self._delegate.size
def getmtime(self): if self._file is None: raise FileClosedError("File closed") # The modification time is not supposed to change over time return self._info[stat.ST_MTIME]
def getsize(self): if self._file is None: raise FileClosedError("File closed") # The size is not supposed to change over time return self._info[stat.ST_SIZE]