delete [] node;
}
-BTree* BTree::Open (const std::string &name)
+BTree::BTree (const std::string &name)
{
/* Leo los bloques recuperables */
- FILE *fp;
- BTree *tree = new BTree ();
-
- std::string del = name + ".del";
+ std::string del = filename + ".del";
fp = fopen (del.c_str (), "wb");
if (fp != NULL) {
uint i;
while (fread (&i, 1, sizeof (uint), fp)) {
- tree->deleted_nodes.push_back (i);
+ deleted_nodes.push_back (i);
}
fclose (fp);
}
- del = name + ".blockdel";
+ del = filename + ".blockdel";
fp = fopen (del.c_str (), "wb");
if (fp != NULL) {
uint i;
while (fread (&i, 1, sizeof (uint), fp)) {
- tree->deleted_block_data.push_back (i);
+ deleted_block_data.push_back (i);
}
fclose (fp);
}
- tree->filename = name;
- tree->fp = fopen (name.c_str(), "rb+");
+ fp = fopen (name.c_str(), "rb+");
if (!fp) {
/* TODO : mandar una exception ? */
- delete tree;
- return NULL;
- }
- tree->ReadFileHeader ();
-
- if (strcmp ("DILUMA", tree->header.magic)) {
- /* Arbol no tiene magic!! */
- delete tree;
- return NULL;
+ return;
}
-
- return tree;
+ ReadFileHeader ();
}
BTree::~BTree ()
class BTree {
public:
BTree (const std::string &filename, unsigned int block_size, int t_t = TYPE_IDENTIFICACION, int k_t = KEY_FIXED, bool create_new_file = false);
-
- static BTree *Open (const std::string &filename);
+ BTree (const std::string &filename);
~BTree ();
/* DEBUG */
- private:
- BTree () {}
-
public:
void PrintNode (uint num);
};