Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5196d00

Browse files
committed
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.
1 parent a220e67 commit 5196d00

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

Mac/scripts/binhextree.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,44 @@ class MwShell(aetools.TalkTo, Metrowerks_Shell_Suite, Required_Suite):
3232
# Helper routines
3333
def binhexit(path, name):
3434
dstfile = path + '.hqx'
35-
if os.path.exists(dstfile) and \
36-
os.stat(dstfile)[8] > os.stat(path)[8]:
37-
print 'Skip', path,'- Up-to-date'
38-
return
35+
if os.path.exists(dstfile):
36+
print 'Compare', path,'...',
37+
if binhexcompare(path, dstfile):
38+
print 'Identical, skipped.'
39+
return
40+
else:
41+
print 'Not up-to-date.'
3942
print 'Binhexing', path
4043
binhex.binhex(path, dstfile)
4144

45+
def binhexcompare(source, hqxfile):
46+
"""(source, hqxfile) - Check whether the two files match (forks only)"""
47+
ifp = binhex.HexBin(hqxfile)
48+
49+
sfp = open(source, 'rb')
50+
while 1:
51+
d = ifp.read(128000)
52+
d2 = sfp.read(128000)
53+
if d <> d2:
54+
return 0
55+
if not d: break
56+
sfp.close()
57+
ifp.close_data()
58+
59+
d = ifp.read_rsrc(128000)
60+
if d:
61+
sfp = binhex.openrsrc(source, 'rb')
62+
d2 = sfp.read(128000)
63+
if d <> d2:
64+
return 0
65+
while 1:
66+
d = ifp.read_rsrc(128000)
67+
d2 = sfp.read(128000)
68+
if d <> d2:
69+
return 0
70+
if not d: break
71+
return 1
72+
4273
# Project files to handle
4374
project_files = {}
4475

0 commit comments

Comments
 (0)