]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Removed seeks beyond eof (MW doesn't support them)
authorJack Jansen <jack.jansen@cwi.nl>
Sun, 23 Apr 1995 22:10:18 +0000 (22:10 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Sun, 23 Apr 1995 22:10:18 +0000 (22:10 +0000)
Mac/Lib/dbmac.py

index 68a832debf37786ad132de9882750d2cb3774d51..1f15ebe41202c3a53c2048540be693e9133bc7b0 100644 (file)
@@ -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))