Exemplo n.º 1
0
void __fastcall TCDirectoryOutline::BuildOneLevel(long RootItem)
{
    TOutlineNode *RootNode = Items[RootItem];
    AnsiString RootName = RootNode->FullPath;

    if (!RootName.IsPathDelimiter(RootName.Length()))
        RootName += "\\";
    RootName += "*.*";

    for (FileFind Find(RootName, faDirectory); Find.Ok; Find.Next()) {
        TSearchRec &SRec = Find.GetSRec();

        // only store directories, ignoring "." and ".."
        if ((SRec.Attr & faDirectory) && SRec.Name[1] != '.') {
            AnsiString Name = ForceCase(SRec.Name);

            if (RootNode->HasItems) { // insert in sorted order
                long Child = RootNode->getFirstChild();
                while (Child != InvalidIndex &&
                        Items[Child]->Text.AnsiCompareIC(Name) < 0)
                    Child = RootNode->GetNextChild(Child);

                if (Child != InvalidIndex)
                    Insert(Child, Name);
                else
                    Add(RootNode->GetLastChild(), Name);
            }
            else
                AddChild(RootItem, Name);
        }
    }
    // mark this node with an arbitrary address so we can tell we've
    // already been here
    Items[RootItem]->Data = APointer;
}