summaryrefslogtreecommitdiffstats
path: root/Mac/Lib
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1995-04-23 22:10:18 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1995-04-23 22:10:18 (GMT)
commit1ff2f218cafa13b0b216006c3de5f0d15386ae82 (patch)
tree4abe36c18bf36ac333c16dc30a86d4685cf803c3 /Mac/Lib
parente99c824bad777224cdba0ea3f2ca6ef4bc94701f (diff)
downloadcpython-1ff2f218cafa13b0b216006c3de5f0d15386ae82.zip
cpython-1ff2f218cafa13b0b216006c3de5f0d15386ae82.tar.gz
cpython-1ff2f218cafa13b0b216006c3de5f0d15386ae82.tar.bz2
Removed seeks beyond eof (MW doesn't support them)
Diffstat (limited to 'Mac/Lib')
-rw-r--r--Mac/Lib/dbmac.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Mac/Lib/dbmac.py b/Mac/Lib/dbmac.py
index 68a832d..1f15ebe 100644
--- a/Mac/Lib/dbmac.py
+++ b/Mac/Lib/dbmac.py
@@ -29,6 +29,12 @@ class _Database:
self._dirfile = file + '.dir'
self._datfile = file + '.dat'
self._bakfile = file + '.bak'
+ # Mod by Jack: create data file if needed
+ try:
+ f = _open(self._datfile, 'r')
+ except IOError:
+ f = _open(self._datfile, 'w')
+ f.close()
self._update()
def _update(self):
@@ -67,8 +73,13 @@ class _Database:
f = _open(self._datfile, 'rb+')
f.seek(0, 2)
pos = f.tell()
- pos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE
- f.seek(pos)
+## Does not work under MW compiler
+## pos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE
+## f.seek(pos)
+ npos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE
+ f.write('\0'*(npos-pos))
+ pos = npos
+
f.write(val)
f.close()
return (pos, len(val))