int recursive_remove(iNode * current) { int ret; if (current->gid < currentUsr.group) return 1; if (is_base_case(current)) //CASOBASE QUE ES QUE EL DIRECTORIO ESTE VACIO O SEA UN ARCHIVO) return 0; int init_block = current->data.direct_blocks[0]; directoryEntry * dr = (directoryEntry*) calloc(sizeof(directoryEntry), 96); read_disk(0, init_block, dr, BLOCK_SIZE * 12, 0); int i; for (i = 2; i < 96; i++) { if (dr[i].type != 0) { ret = recursive_remove(fs_get_inode(dr[i].inode)); if (!ret) { dr[i].type = 0; dr[i].inode = 0; dr[i].lenght = 0; } } } write_disk(0, init_block, dr, BLOCK_SIZE * 12, 0); return ret; }
kdnode * kdtree::recursive_remove(kdnode * node) { if ( (node->get_right() == nullptr) && (node->get_left() == nullptr) ) { return nullptr; } unsigned int discriminator = node->get_discriminator(); /* Check if only left branch exist */ if (node->get_right() == nullptr) { node->set_right(node->get_left()); node->set_left(nullptr); } /* Find minimal node in line with coordinate that is defined by discriminator */ kdnode * minimal_node = find_minimal_node(node->get_right(), discriminator); kdnode * parent = minimal_node->get_parent(); if (parent->get_left() == minimal_node) { parent->set_left(recursive_remove(minimal_node)); } else if (parent->get_right() == minimal_node) { parent->set_right(recursive_remove(minimal_node)); } else { throw std::runtime_error("Structure of KD Tree is corrupted"); } minimal_node->set_parent(node->get_parent()); minimal_node->set_discriminator(node->get_discriminator()); minimal_node->set_right(node->get_right()); minimal_node->set_left(node->get_left()); /* Update parent for successors of previous parent */ if (minimal_node->get_right() != nullptr) { minimal_node->get_right()->set_parent(minimal_node); } if (minimal_node->get_left() != nullptr) { minimal_node->get_left()->set_parent(minimal_node); } return minimal_node; }
void Directory::remove() { if (!parent_.is_nil()) parent_->removing(logical_dirname_, false); parent_ = 0; recursive_remove(physical_dirname_); overflow_.clear(); files_.clear(); dirs_.clear(); long_names_.clear(); }
bool recursive_remove(int id) { int i, id2; for(i = 0; i < items[id].usr.size(); ++i) if(items[id2 = items[id].usr[i]].inst != NOT_INST) return false; std::printf(" Removing %s\n", items[id].name); items[id].inst = NOT_INST; inst_list.erase(std::find(inst_list.begin(), inst_list.end(), id)); for(i = 0; i < items[id].dep.size(); ++i) if(items[id2 = items[id].dep[i]].inst == IMP_INST) recursive_remove(id2); return true; }
void remove(char *item) { int id; std::map<std::string, int>::iterator it = idx.find(item); if(it == idx.end()) id = add_new_item(item); else id = it->second; if(items[id].inst != NOT_INST) { if(!recursive_remove(id)) std::printf(" %s is still needed.\n", item); } else std::printf(" %s is not installed.\n", item); }
S triefort_destroy(const char * const path) { S s = triefort_ok; sds spath = sdsnew(path); spath = sdscat(spath, "/" CONFIG_FILE_NAME); if (!file_exists(spath)) { s = triefort_err_not_a_triefort; } else { if (0 != recursive_remove(path)) { s = triefort_err_path_could_not_be_destroyed; } } sdsfree(spath); return s; }
S triefort_drop(TF * const fort, const void * const hash) { NULLCHK(fort); NULLCHK(hash); sds path = trie_dir_path(fort, hash, NULL); S s; if (dir_exists(path)) { recursive_remove(path); s = triefort_ok; } else { s = triefort_err_hash_does_not_exist; } sdsfree(path); return s; }
void kdtree::remove(kdnode * node_for_remove) { kdnode * parent = node_for_remove->get_parent(); kdnode * node = recursive_remove(node_for_remove); if (parent == nullptr) { root = node; /* if tree is almost destroyed */ if (node != nullptr) { node->set_parent(nullptr); } } else { if (parent->get_left() == node_for_remove) { parent->set_left(node); } else if (parent->get_right() == node_for_remove) { parent->set_right(node); } else { throw std::runtime_error("Structure of KD Tree is corrupted"); } } }
/* * Class: EmU_Login * Method: uninit_backend * Signature: ()V */ JNIEXPORT void JNICALL Java_EmU_1Login_uninit_1backend(JNIEnv *env, jobject obj) { recursive_remove(CACHE_DIRECTORY_PATH); uninit_openssl(); }
/* * Class: EmU_PHRAuthorityManagement * Method: uninit_backend * Signature: ()V */ JNIEXPORT void JNICALL Java_EmU_1PHRAuthorityManagement_uninit_1backend(JNIEnv *env, jobject obj) { recursive_remove(CACHE_DIRECTORY_PATH); uninit_openssl(); }
/* * Class: MailServerConfigurationChanging * Method: uninit_backend * Signature: ()V */ JNIEXPORT void JNICALL Java_MailServerConfigurationChanging_uninit_1backend(JNIEnv *env, jobject obj) { recursive_remove(CACHE_DIRECTORY_PATH); uninit_openssl(); }
/* * Class: NewPasswordChanging * Method: uninit_backend * Signature: ()V */ JNIEXPORT void JNICALL Java_NewPasswordChanging_uninit_1backend(JNIEnv *env, jobject obj) { recursive_remove(CACHE_DIRECTORY_PATH); uninit_openssl(); }
void rmDir(char * path) { int i, j, ret; iNode * posible_inode = current; posible_inode = parser_path(path, posible_inode); if (posible_inode == NULL) { printf("Wrong name or path\n"); return; } if (posible_inode->gid < currentUsr.group) { printf("\nCan not remove %s. Permission denied.", path); return; } if (posible_inode->identifier != DIRECTORY) { int inode_number = posible_inode->iNode_number; int init_block = current->data.direct_blocks[0]; directoryEntry * dr = (directoryEntry*) calloc(sizeof(directoryEntry), 96); read_disk(0, init_block, dr, BLOCK_SIZE * 12, 0); for (i = 2; i < 96; i++) { if (dr[i].inode == inode_number) { char * empty_name = "\0"; dr[i].type = 0; dr[i].inode = 0; dr[i].lenght = 0; strcopy(dr[i].name, empty_name, 1); break; } } write_disk(0, init_block, dr, BLOCK_SIZE * 12, 0); } else { //BORRADO RECURSIVO. ret = recursive_remove(posible_inode); if (ret) return; int inode_number = posible_inode->iNode_number; int init_block = current->data.direct_blocks[0]; directoryEntry * dr = (directoryEntry*) calloc(sizeof(directoryEntry), 96); read_disk(0, init_block, dr, BLOCK_SIZE * 12, 0); iNode * parent = fs_get_inode(dr[1].inode); int father_init_block = current->data.direct_blocks[0]; directoryEntry * father_dr = (directoryEntry*) calloc( sizeof(directoryEntry), 96); read_disk(0, father_init_block, father_dr, BLOCK_SIZE * 12, 0); for (i = 2; i < 96; i++) { if (father_dr[i].inode == inode_number) { char * empty_name = "\0"; dr[i].type = 0; dr[i].inode = 0; dr[i].lenght = 0; strcopy(dr[i].name, empty_name, 1); break; } } write_disk(0, init_block, dr, BLOCK_SIZE * 12, 0); } return; }