def pread(self, size=None, pos=None): """Read *pos*-length data starting from position *pos*. This operation doesn't change the pointer position.""" size = int(self.size) if size is None else int(size) pos = int(self.pos if pos is None else pos) if size < 0: raise ValueError("invalid size, %d" % size) chunk = unistd.pread(self.fd, size, pos) return chunk
def read(self, size=None, pos=None): """Read *pos*-length data starting from position *pos*.""" size = int(self.size) if size is None else int(size) pos = int(self.pos if pos is None else pos) if size < 0: raise ValueError("invalid size, %d" % size) chunk = unistd.pread(self.fd, size, pos) self.pos = pos + len(chunk) return chunk