Panda3D
Public Member Functions | Public Attributes | List of all members
FileSpec Class Reference

Public Member Functions

def __init__ (self)
 
def checkHash (self, packageDir, pathname, st)
 
def fromFile (self, packageDir, filename, pathname=None, st=None)
 
def fullVerify (self, packageDir=None, pathname=None, notify=None)
 
def loadXml (self, xelement)
 
def quickVerify (self, packageDir=None, pathname=None, notify=None, correctSelf=False)
 
def readHash (self, pathname)
 
def storeMiniXml (self, xelement)
 
def storeXml (self, xelement)
 

Public Attributes

 actualFile
 
 basename
 
 filename
 
 hash
 
 size
 
 timestamp
 

Detailed Description

This class represents a disk file whose hash and size
etc. were read from an xml file.  This class provides methods to
verify whether the file on disk matches the version demanded by
the xml. 

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Member Function Documentation

◆ checkHash()

def checkHash (   self,
  packageDir,
  pathname,
  st 
)
Returns true if the file has the expected md5 hash, false
otherwise.  As a side effect, stores a FileSpec corresponding
to the on-disk file in self.actualFile. 

◆ fromFile()

def fromFile (   self,
  packageDir,
  filename,
  pathname = None,
  st = None 
)
Reads the file information from the indicated file.  If st
is supplied, it is the result of os.stat on the filename. 

◆ fullVerify()

def fullVerify (   self,
  packageDir = None,
  pathname = None,
  notify = None 
)
Performs a more thorough test to ensure the file has not
been modified.  This test is less vulnerable to malicious
attacks, since it reads and verifies the entire file.

Returns true if it is intact, false if it needs to be
redownloaded. 

◆ loadXml()

def loadXml (   self,
  xelement 
)
Reads the file information from the indicated XML
element. 

◆ quickVerify()

def quickVerify (   self,
  packageDir = None,
  pathname = None,
  notify = None,
  correctSelf = False 
)
Performs a quick test to ensure the file has not been
modified.  This test is vulnerable to people maliciously
attempting to fool the program (by setting datestamps etc.).

if correctSelf is True, then any discrepency is corrected by
updating the appropriate fields internally, making the
assumption that the file on disk is the authoritative version.

Returns true if it is intact, false if it is incorrect.  If
correctSelf is true, raises OSError if the self-update is
impossible (for instance, because the file does not exist).

◆ readHash()

def readHash (   self,
  pathname 
)
Reads the hash only from the indicated pathname. 

◆ storeMiniXml()

def storeMiniXml (   self,
  xelement 
)
Adds the just the "mini" file information--size and
hash--to the indicated XML element. 

◆ storeXml()

def storeXml (   self,
  xelement 
)
Adds the file information to the indicated XML
element. 

Member Data Documentation

◆ actualFile

actualFile

◆ basename

basename

◆ filename

filename

◆ hash

hash

◆ size

size

◆ timestamp

timestamp