Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
FileSpec Class Reference

Public Member Functions

 __init__ (self)
 
 checkHash (self, packageDir, pathname, st)
 
 fromFile (self, packageDir, filename, pathname=None, st=None)
 
 fullVerify (self, packageDir=None, pathname=None, notify=None)
 
 loadXml (self, xelement)
 
 quickVerify (self, packageDir=None, pathname=None, notify=None, correctSelf=False)
 
 readHash (self, pathname)
 
 storeMiniXml (self, xelement)
 
 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__()

__init__ ( self)

Member Function Documentation

◆ checkHash()

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()

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()

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()

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

◆ quickVerify()

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()

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

◆ storeMiniXml()

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

◆ storeXml()

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