Exemple #1
0
static link_t delete_recursive_all(link_t root, int key)
{
    if (root == null_link) return null_link;

    root->left = delete_recursive(root->left, key);
    root->right = delete_recursive(root->right, key);
    if (key == root->key) {
        link_t tmp = root;
        root = join_lr(root->left, root->right);
        dellink(&tmp);
    }

    return root;

}
Exemple #2
0
static bool delete_recursive(const char *dir)
{
	struct direntry *filelist, *fl;
	bool err = false;
	unsigned int nbr, i;

	i = nbr = BLI_dir_contents(dir, &filelist);
	fl = filelist;
	while (i--) {
		char file[8];
		BLI_split_file_part(fl->path, file, sizeof(file));
		if (STREQ(file, ".") || STREQ(file, "..")) {
			/* Skip! */
		}
		else if (S_ISDIR(fl->type)) {
			if (delete_recursive(fl->path)) {
				err = true;
			}
		}
		else {
			if (delete_unique(fl->path, false)) {
				err = true;
			}
		}
		++fl;
	}

	if (!err && delete_unique(dir, true)) {
		err = true;
	}

	BLI_free_filelist(filelist, nbr);

	return err;
}
Exemple #3
0
void USBViewer::refresh()
{
    QIntDict< QListViewItem > new_items;

    if(!USBDevice::parse("/proc/bus/usb/devices"))
        USBDevice::parseSys("/sys/bus/usb/devices");

    int level = 0;
    bool found = true;

    while(found)
    {
        found = false;

        QPtrListIterator< USBDevice > it(USBDevice::devices());
        for(; it.current(); ++it)
            if(it.current()->level() == level)
            {
                Q_UINT32 k = key(*it.current());
                if(level == 0)
                {
                    QListViewItem *item = _items.find(k);
                    if(!item)
                    {
                        item = new QListViewItem(_devices, it.current()->product(), QString::number(k));
                    }
                    new_items.insert(k, item);
                    found = true;
                }
                else
                {
                    QListViewItem *parent = new_items.find(key_parent(*it.current()));
                    if(parent)
                    {
                        QListViewItem *item = _items.find(k);

                        if(!item)
                        {
                            item = new QListViewItem(parent, it.current()->product(), QString::number(k));
                        }
                        new_items.insert(k, item);
                        parent->setOpen(true);
                        found = true;
                    }
                }
            }

        ++level;
    }

    // recursive delete all items not in new_items
    delete_recursive(_devices->firstChild(), new_items);

    _items = new_items;

    if(!_devices->selectedItem())
        selectionChanged(_devices->firstChild());
}
Exemple #4
0
static link_t delete_recursive(link_t root, int key)
{
    if (root == null_link) return null_link;

    root->count--;
    if (key < root->key) {
        root->left = delete_recursive(root->left, key);
    }
    else if (key > root->key) {
        root->right = delete_recursive(root->right, key);
    }
    else { /* key == root->key */
        link_t tmp = root;
        root = join_lr(root->left, root->right);
        dellink(&tmp);
    }

    return root;
}
Exemple #5
0
int BLI_delete(const char *file, bool dir, bool recursive)
{
	int err;

	if (recursive) {
		err = delete_recursive(file);
	}
	else {
		err = delete_unique(file, dir);
	}

	return err;
}
Exemple #6
0
static void delete_recursive(QListViewItem *item, const QIntDict< QListViewItem > &new_items)
{
    if(!item)
        return;

    QListViewItemIterator it(item);
    while(it.current())
    {
        if(!new_items.find(it.current()->text(1).toUInt()))
        {
            delete_recursive(it.current()->firstChild(), new_items);
            delete it.current();
        }
        ++it;
    }
}
Exemple #7
0
static void delete_recursive(entry_ptr_t ent)
{
	if (ent != NULL) {
		if ((ent->next) != NULL) {
			delete_recursive(ent->next);
		}
		free(ent->data->city);
		free(ent->data->zipcode);
		free(ent->data->number);
		free(ent->data->street);
		free(ent->data->lastname);
		free(ent->data->firstname);
		free(ent->next);
		_dbgnice("freed an entry");
	} else {
		_dbgwarn("list is empty");
	}
}
Exemple #8
0
void delete_all(void)
{
	delete_recursive(head);
	head = NULL;
}
Exemple #9
0
void bst_delete(T t, int key)
{
    t->root = delete_recursive(t->root, key);
    /*delete_non_recursive(t, key);*/
}