changed: there is one dir called root (has parent_id -1)

(we have an owner, group, privileges etc of the root dir)
         the root.id of course is not -1 


git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@468 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2008-12-22 16:03:03 +00:00
parent 55cd813141
commit fac60a197b
9 changed files with 117 additions and 48 deletions

View File

@@ -13,6 +13,17 @@
DirContainer::DirContainer()
{
is_root = false;
}
DirContainer::Iterator DirContainer::GetRoot()
{
if( !is_root )
return table.end();
return table.begin() + root_index;
}
@@ -40,6 +51,7 @@ bool DirContainer::Empty()
}
void DirContainer::PushBack(const Item & item)
{
bool rebuild_indexes = false;
@@ -47,8 +59,21 @@ bool rebuild_indexes = false;
if( table.size() == table.capacity() )
rebuild_indexes = true;
if( item.parent_id == -1 )
{
if( is_root )
log << log1 << "DirCont: more than one root dir - skipped, id: " << item.id << logend;
else
{
is_root = true;
root_index = table.size();
}
}
table.push_back(item);
log << log2 << "DirCont: added item, id: " << item.id << ", parent_id: " << item.parent_id << logend;
if( rebuild_indexes )
RebuildIndexes();