diff --git a/btree.cpp b/btree.cpp index 71dd016..bd5ae1f 100644 --- a/btree.cpp +++ b/btree.cpp @@ -135,6 +135,15 @@ if (!vfs->fWrite(node, info->bNodeSize)) exit(42); } // bTree::savePage +void +bTree::saveSuperBlock(void) { + if (memoryTree) return; + + if (!vfs->fSeek(0)) exit(42); + if (!vfs->fWrite(info, sizeof(bTreeInfo))) exit(42); + +} // bTree::saveSuperBlock + void bTree::setFirstDeleted(uPtr value) { info->firstDeleted = value; diff --git a/btree.h b/btree.h index 736b71c..1292c1c 100644 --- a/btree.h +++ b/btree.h @@ -27,7 +27,7 @@ TbNode * loadPage(uPtr); void savePage(TbNode *); - + void saveSuperBlock(void); void setFirstDeleted(uPtr); void setNodes(uInt32); void setHeight(uInt32); diff --git a/lists.pas b/lists.pas index 6375ede..f5a2342 100755 --- a/lists.pas +++ b/lists.pas @@ -1699,14 +1699,11 @@ procedure bTree.saveSuperBlock; begin - if (not(memoryTree)) then - begin + if memoryTree then exit; // if not vfs^.fClose() then writeln('Error calling fClose (for the first time) file in bTree.done()'); // if not vfs^.fOpen(treeName, 1) then writeln('Error calling fOpen in bTree.done()'); - if not vfs^.fSeek(0) then writeln('Error seeking in bTree.saveSuperBlock()'); // reset back to the beginning - if not vfs^.fWrite(info^, sizeof(BTreeInfo)) then writeln('Error saving superblock in bTree.saveSuperBlock()'); - // disposing the vfs pointer will close the file as necessary - end; + if not vfs^.fSeek(0) then writeln('Error seeking in bTree.saveSuperBlock()'); // reset back to the beginning + if not vfs^.fWrite(info^, sizeof(BTreeInfo)) then writeln('Error saving superblock in bTree.saveSuperBlock()'); end; // bTree.saveSuperBlock