diff --git a/btree.cpp b/btree.cpp index a4caf67..661a691 100644 --- a/btree.cpp +++ b/btree.cpp @@ -79,11 +79,30 @@ return info->keys; } // bTree::getKeys + +uPtr +bTree::getRoot(void) { + + if (info == NULL) { + uPtr result; + setNull(result); + return result; + } // if info == NULL + + if (!memoryTree) { + if (!vfs->fSeek((int)&info->root - (int)info)) exit(42); + if (!vfs->fRead(&info->root, sizeof(info->root))) exit(42); + } // if not memoryTree + + return info->root; +} // bTree::getRoot + void bTree::setNull(uPtr & u) { u.offset = 0; } // bTree::setNull + void bTree::InstallUserFunctions(compareKeyFunc cmpFunc, copyKeyProc copyProc, keySizeFunc ksFunc) { compareKey = cmpFunc; diff --git a/btree.h b/btree.h index 12eb9fb..ef5f306 100644 --- a/btree.h +++ b/btree.h @@ -21,6 +21,7 @@ uInt32 getNodes(void); uInt32 getHeight(void); uInt32 getKeys(void); + uPtr getRoot(void); void setNull(uPtr &); public: bTree(char *, uInt32, treeTypes, bTreeVFS *);