X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/blobdiff_plain/3a9e92af5fe004d068e161c66e308e4401dfc21b..dba24fb6aa7fe829dc3e96039e7f717b0ef9668e:/src/btree.cpp diff --git a/src/btree.cpp b/src/btree.cpp index 9591ec8..c7d3b4b 100644 --- a/src/btree.cpp +++ b/src/btree.cpp @@ -17,7 +17,7 @@ BTree::BTree (const std::string &name, unsigned int block_size, bool create_new_ /* Inicializo el header */ header.block_size = block_size; - write_tree_header (); + WriteFileHeader (); /* Creo el primer bloque vacio */ node = new uchar[block_size]; @@ -26,7 +26,7 @@ BTree::BTree (const std::string &name, unsigned int block_size, bool create_new_ nh.free_space = block_size - sizeof (BTreeNodeHeader); nh.item_count = 0; WriteNodoHeader (node, &nh); - write_block (node, 0); + WriteBlock (node, 0); delete [] node; } @@ -36,13 +36,13 @@ BTree::~BTree () fclose (fp); } -void BTree::write_tree_header () +void BTree::WriteFileHeader () { fseek (fp, 0L, SEEK_SET); fwrite (&header, 1, sizeof (BTreeFileHeader), fp); } -void BTree::write_block (uchar *block, uint num) +void BTree::WriteBlock (uchar *block, uint num) { fseek (fp, num*header.block_size + sizeof (BTreeFileHeader), SEEK_SET); fwrite (block, 1, header.block_size, fp); @@ -66,6 +66,11 @@ void BTree::AddKey (const Clave &k) std::cout << "__NO__ hay lugar para meter la clave" << std::endl; } + + WriteKeys (root, root_header, node_keys); + WriteNodoHeader (root, &root_header); + WriteBlock (root, 0); + delete [] root; }