Compare sourcefile to hqx file (if it exists) before binhexing. This

should stop us from continually updating the .hqx files, at least for
resource files.
This commit is contained in:
Jack Jansen 1996-03-25 15:38:36 +00:00
parent a220e67a9e
commit 5196d00cc6
1 changed files with 35 additions and 4 deletions

View File

@ -32,13 +32,44 @@ CWDIR=':Mac:mwerks:projects'
# Helper routines # Helper routines
def binhexit(path, name): def binhexit(path, name):
dstfile = path + '.hqx' dstfile = path + '.hqx'
if os.path.exists(dstfile) and \ if os.path.exists(dstfile):
os.stat(dstfile)[8] > os.stat(path)[8]: print 'Compare', path,'...',
print 'Skip', path,'- Up-to-date' if binhexcompare(path, dstfile):
return print 'Identical, skipped.'
return
else:
print 'Not up-to-date.'
print 'Binhexing', path print 'Binhexing', path
binhex.binhex(path, dstfile) binhex.binhex(path, dstfile)
def binhexcompare(source, hqxfile):
"""(source, hqxfile) - Check whether the two files match (forks only)"""
ifp = binhex.HexBin(hqxfile)
sfp = open(source, 'rb')
while 1:
d = ifp.read(128000)
d2 = sfp.read(128000)
if d <> d2:
return 0
if not d: break
sfp.close()
ifp.close_data()
d = ifp.read_rsrc(128000)
if d:
sfp = binhex.openrsrc(source, 'rb')
d2 = sfp.read(128000)
if d <> d2:
return 0
while 1:
d = ifp.read_rsrc(128000)
d2 = sfp.read(128000)
if d <> d2:
return 0
if not d: break
return 1
# Project files to handle # Project files to handle
project_files = {} project_files = {}