Esempio n. 1
0
bool mv(char *arg1,char * arg2){
	char * str = malloc(sizeof(arg1));
	strcpy(str, arg1);
	vfile * target = getFileByString(arg1);
	dir * targetDir = getDirectoryByString(str);
	dir * destination = getDirectoryByString(arg2);
	int i,targetPos;
	if (destination->filePoses[0]==-1) i=0;
	else for (i = 0; destination->filePoses[i]!=-1; i++);
	if(targetDir->filePoses[0]==-1) return false;
	else for (int j=0;targetDir->filePoses[j]!=-1;j++){
		vfile * tmp = malloc(sizeof(vfile));
		fseek ( vfs , targetDir->filePoses[j] , SEEK_SET );
		fread(tmp,sizeof(dir),1,vfs);
		if (strcmp(target->fileName, tmp->fileName)==0) {
			targetPos=targetDir->filePoses[j];
			free(tmp);
			break;
		}else free(tmp);
	}
	destination->filePoses[i] =targetPos;
	destination->filePoses[i+1] = -1;
	fseek ( vfs , destination->pos , SEEK_SET );
	fwrite(destination,sizeof(dir),1,vfs);
	removeLeaf(targetDir,target->fileName);
	return true;
}
Esempio n. 2
0
void SWDynamicTree2D::destroyProxy( tuint proxyID )
{
	if ( proxyID >= m_nodes.size() ) return;

	removeLeaf( proxyID );
	freeNode( proxyID );
}
Esempio n. 3
0
File: trie.c Progetto: starsep/Trie
//jeżeli należy to usuwa node'a
void deleteNode(Node *node){
	assert(node != NULL);
	if(node->numberOfWord != NO_END_OF_WORD)
		endOfWord[node->numberOfWord] = NULL;
	node->numberOfWord = NO_END_OF_WORD;
	if(node->numberOfSons == 0)
		removeLeaf(node);
	else if(node->numberOfSons == 1)
		joinFatherWithOnlySon(node);
	if(numberOfNodes < 2)
		clearTrie();
}
Esempio n. 4
0
NodeOfTree *removeKey(NodeOfTree *root, TypeOfKey key)
{
	NodeOfTree *nodeWithKey = findKey(root, key);
	if (nullptr == nodeWithKey)
	{
		return root; 
	}
	if ((nodeWithKey->left == nullptr && nodeWithKey->right == nullptr) || (nodeWithKey->left != nullptr && nodeWithKey->right == nullptr) || (nodeWithKey->left == nullptr && nodeWithKey->right != nullptr))
	{
		root = removeLeaf(root, nodeWithKey);
		return root;
	}
	if (nodeWithKey->left != nullptr && nodeWithKey->right != nullptr)
	{
		NodeOfTree *temp = rightMost(nodeWithKey);
		TypeOfKey tempOfKey = temp->key;
		root = removeLeaf(root, temp);
		nodeWithKey->key = tempOfKey;
		return root;
	}
	return root;
}
//------------------------------------------------------------------*
void
    CSysVarPool::ClearSysVar()
{
    for (POSITION pos = m_sysVarMap.GetStartPosition(); pos != NULL; )
    {
        CString strName;
        CSysVar *pVar = NULL;
        m_sysVarMap.GetNextAssoc(pos, strName, pVar);
        assert(pVar != NULL);
        removeLeaf(pVar);
        pVar->release();
    }
    m_sysVarMap.RemoveAll();
}
Esempio n. 6
0
bool SWDynamicTree2D::updateProxy( tuint proxyID, const taabb2d& aabb )
{
	if ( proxyID >= m_nodes.size() ) return false;

	TreeNode& node = m_nodes[proxyID];
	if ( node.aabb.contains( aabb ) ) return false;

	removeLeaf( proxyID );

	tvec2 extention( SW_AddedExtension, SW_AddedExtension );
	node.aabb = aabb;
	node.aabb.lower -= extention;
	node.aabb.upper += extention;

	insertLeaf( proxyID );

	return true;
}
/**
 * AddSysVar
 *
 * @param           
 * @return          S_OK; 
 * @exception       -
*/
HRESULT
    CSysVarPool::AddSysVar(CSysVar *pVar)
{
    HRESULT hr;
    if (pVar == NULL) {
        return E_POINTER;
    }
    CSysVar *pVarTest = NULL;
    CString strName = pVar->getName();
    strName.MakeLower();
    if (m_sysVarMap.Lookup(strName, pVarTest)) {
        // already in map, refuse!
        return S_FALSE;
    }
    addLeaf(pVar);
    hr = pVar->Reread();
    if (FAILED(hr)) {
        removeLeaf(pVar);
        return hr;
    }
    pVar->addRef();
    m_sysVarMap.SetAt(strName, pVar);
    return S_OK;
}