// note - you still need to delete the file yourself bool RDirNode::removeFile(RFile* f) { //doesnt match this path at all if(f->path.find(abspath) != 0) { return false; } //is this dir - add to this node if(f->path.compare(abspath) == 0) { for(std::list<RFile*>::iterator it = files.begin(); it != files.end(); it++) { if((*it)==f) { files.erase(it); if(!f->isHidden()) visible_count--; fileUpdated(false); return true; } } return false; } //does this belong to one of the children ? for(std::list<RDirNode*>::iterator it = children.begin(); it != children.end(); it++) { RDirNode* node = (*it); bool removed = node->removeFile(f); if(removed) { //fprintf(stderr, "%s file removed from a child. child file count=%d, dir count =%d\n", getPath().c_str(), node->fileCount(), node->dirCount()); //node->printFiles(); //node is now empty, reap! if(node->noFiles() && node->noDirs()) { children.erase(it); //fprintf(stderr, "deleting node %s from %s\n", node->getPath().c_str(), getPath().c_str()); delete node; nodeUpdated(false); } return true; } } return false; }