File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ def __init__(self, file):
2929 self ._dirfile = file + '.dir'
3030 self ._datfile = file + '.dat'
3131 self ._bakfile = file + '.bak'
32+ # Mod by Jack: create data file if needed
33+ try :
34+ f = _open (self ._datfile , 'r' )
35+ except IOError :
36+ f = _open (self ._datfile , 'w' )
37+ f .close ()
3238 self ._update ()
3339
3440 def _update (self ):
@@ -67,8 +73,13 @@ def _addval(self, val):
6773 f = _open (self ._datfile , 'rb+' )
6874 f .seek (0 , 2 )
6975 pos = f .tell ()
70- pos = ((pos + _BLOCKSIZE - 1 ) / _BLOCKSIZE ) * _BLOCKSIZE
71- f .seek (pos )
76+ ## Does not work under MW compiler
77+ ## pos = ((pos + _BLOCKSIZE - 1) / _BLOCKSIZE) * _BLOCKSIZE
78+ ## f.seek(pos)
79+ npos = ((pos + _BLOCKSIZE - 1 ) / _BLOCKSIZE ) * _BLOCKSIZE
80+ f .write ('\0 ' * (npos - pos ))
81+ pos = npos
82+
7283 f .write (val )
7384 f .close ()
7485 return (pos , len (val ))
You can’t perform that action at this time.
0 commit comments