diff --git a/src/sys/ubixfsv2/btree.cpp b/src/sys/ubixfsv2/btree.cpp index b6b99a6..9c8ef75 100644 --- a/src/sys/ubixfsv2/btree.cpp +++ b/src/sys/ubixfsv2/btree.cpp @@ -41,7 +41,32 @@ ubixfsInode * tmpInode = NULL; unsigned int curSlot = 0; - if (bnode == NULL || inode == NULL) return false; + if (inode == NULL) return false; + + // note: this code is right out of the constructor + if (root == NULL) { + treeDepth = 1; + treeWidth = 0; + treeLeafCount = 0; + root = allocEmptyNode(); + assert(root); + if (root == NULL) return false; + + root->used = 1; + root->parent = NULL; + root->leaf = true; + root->childCount[1] = 1; + + strncpy(root->keys[0], inode->name, B_MAX_NAME_LENGTH); + // insert pointer to data page to the right of the data + root->head[1] = (void *)inode; + root->tail[1] = (void *)inode; + + root->present[1] = true; + inode->next = inode->prev = NULL; + return true; + } // if + tmpInode = Find(inode->name); if (tmpInode != NULL) return false; // PrintWholeTree(); @@ -587,6 +612,7 @@ bool bTree::Save(const char * filename) { if (filename == NULL) return false; + return true; } // bTree::Save diff --git a/src/sys/ubixfsv2/main.cpp b/src/sys/ubixfsv2/main.cpp index 16cdda5..d01ba64 100644 --- a/src/sys/ubixfsv2/main.cpp +++ b/src/sys/ubixfsv2/main.cpp @@ -142,8 +142,8 @@ tmpInode = tmpInode->next; } // while -// cout << sizeof(struct bNode) << endl; -// cout << sizeof(struct ubixfsInode) << endl; +cout << sizeof(struct bNode) << endl; +cout << sizeof(struct ubixfsInode) << endl; // tree->Info(); free(inode);