Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.tarfile._FileInFile Class Reference

List of all members.

Public Member Functions

def __init__
def tell
def seek
def read
def readnormal
def readsparse
def readsparsesection

Public Attributes

 fileobj
 offset
 size
 sparse
 position

Detailed Description

A thin wrapper around an existing file object that
   provides a part of its data as an individual file
   object.

Definition at line 644 of file tarfile.py.


Constructor & Destructor Documentation

def MoinMoin.support.tarfile._FileInFile.__init__ (   self,
  fileobj,
  offset,
  size,
  sparse = None 
)

Definition at line 650 of file tarfile.py.

00650 
00651     def __init__(self, fileobj, offset, size, sparse=None):
00652         self.fileobj = fileobj
00653         self.offset = offset
00654         self.size = size
00655         self.sparse = sparse
00656         self.position = 0


Member Function Documentation

def MoinMoin.support.tarfile._FileInFile.read (   self,
  size = None 
)
Read data from the file.

Definition at line 667 of file tarfile.py.

00667 
00668     def read(self, size=None):
00669         """Read data from the file.
00670         """
00671         if size is None:
00672             size = self.size - self.position
00673         else:
00674             size = min(size, self.size - self.position)
00675 
00676         if self.sparse is None:
00677             return self.readnormal(size)
00678         else:
00679             return self.readsparse(size)

Here is the call graph for this function:

Here is the caller graph for this function:

Read operation for regular files.

Definition at line 680 of file tarfile.py.

00680 
00681     def readnormal(self, size):
00682         """Read operation for regular files.
00683         """
00684         self.fileobj.seek(self.offset + self.position)
00685         self.position += size
00686         return self.fileobj.read(size)

Here is the caller graph for this function:

Read operation for sparse files.

Definition at line 687 of file tarfile.py.

00687 
00688     def readsparse(self, size):
00689         """Read operation for sparse files.
00690         """
00691         data = []
00692         while size > 0:
00693             buf = self.readsparsesection(size)
00694             if not buf:
00695                 break
00696             size -= len(buf)
00697             data.append(buf)
00698         return "".join(data)

Here is the call graph for this function:

Here is the caller graph for this function:

Read a single section of a sparse file.

Definition at line 699 of file tarfile.py.

00699 
00700     def readsparsesection(self, size):
00701         """Read a single section of a sparse file.
00702         """
00703         section = self.sparse.find(self.position)
00704 
00705         if section is None:
00706             return ""
00707 
00708         size = min(size, section.offset + section.size - self.position)
00709 
00710         if isinstance(section, _data):
00711             realpos = section.realpos + self.position - section.offset
00712             self.fileobj.seek(self.offset + realpos)
00713             self.position += size
00714             return self.fileobj.read(size)
00715         else:
00716             self.position += size
00717             return NUL * size
00718 #class _FileInFile
00719 

Here is the caller graph for this function:

def MoinMoin.support.tarfile._FileInFile.seek (   self,
  position 
)
Seek to a position in the file.

Definition at line 662 of file tarfile.py.

00662 
00663     def seek(self, position):
00664         """Seek to a position in the file.
00665         """
00666         self.position = position

Return the current file position.

Definition at line 657 of file tarfile.py.

00657 
00658     def tell(self):
00659         """Return the current file position.
00660         """
00661         return self.position


Member Data Documentation

Definition at line 651 of file tarfile.py.

Definition at line 652 of file tarfile.py.

Definition at line 655 of file tarfile.py.

Definition at line 653 of file tarfile.py.

Definition at line 654 of file tarfile.py.


The documentation for this class was generated from the following file: