예제 #1
0
 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)))
예제 #2
0
 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)))
예제 #3
0
 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))))
예제 #4
0
 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)))
예제 #5
0
 def seek(self, offset):
     if self._delegate is None:
         raise FileClosedError("File closed")
     return self._delegate.seek(offset)
예제 #6
0
 def tell(self):
     if self._delegate is None:
         raise FileClosedError("File closed")
     return self._delegate.tell()
예제 #7
0
 def getsize(self):
     if self._delegate is None:
         raise FileClosedError("File closed")
     return self._delegate.size
예제 #8
0
 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]
예제 #9
0
 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]