summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1996-03-25 15:38:36 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1996-03-25 15:38:36 (GMT)
commit5196d00cc693070da9ff8eed406921347033a1ed (patch)
treebfd7e08d79b0d0d68a76687fafa2b5e29fdfa3ef
parenta220e67a9ed94d66b81e393a3bb9e6acd10068c1 (diff)
downloadcpython-5196d00cc693070da9ff8eed406921347033a1ed.zip
cpython-5196d00cc693070da9ff8eed406921347033a1ed.tar.gz
cpython-5196d00cc693070da9ff8eed406921347033a1ed.tar.bz2
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.
-rw-r--r--Mac/scripts/binhextree.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/Mac/scripts/binhextree.py b/Mac/scripts/binhextree.py
index 85b8a6c..fa67b9c 100644
--- a/Mac/scripts/binhextree.py
+++ b/Mac/scripts/binhextree.py
@@ -32,13 +32,44 @@ CWDIR=':Mac:mwerks:projects'
# Helper routines
def binhexit(path, name):
dstfile = path + '.hqx'
- if os.path.exists(dstfile) and \
- os.stat(dstfile)[8] > os.stat(path)[8]:
- print 'Skip', path,'- Up-to-date'
- return
+ if os.path.exists(dstfile):
+ print 'Compare', path,'...',
+ if binhexcompare(path, dstfile):
+ print 'Identical, skipped.'
+ return
+ else:
+ print 'Not up-to-date.'
print 'Binhexing', path
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 = {}