/* copy atribytes */
bool
BF_GUI_FilesPanel_CopyTask::Copy_Atributes(BNode & o_NodeSrc,BNode & o_NodeDest)
{
    char 		pcName[B_ATTR_NAME_LENGTH];
    attr_info	uAttrInfo;
    uint32		iBufMaxSize=255;
    char		*pcBuf = (char*)malloc(iBufMaxSize);

    o_NodeSrc.RewindAttrs();
    //
    while(B_OK==o_NodeSrc.GetNextAttrName(pcName)) {
        if(B_OK==o_NodeSrc.GetAttrInfo(pcName,&uAttrInfo)) {
            /* check buffer size  */
            if(uAttrInfo.size>iBufMaxSize) {
                DELETE(pcBuf);
                iBufMaxSize = uAttrInfo.size;
                pcBuf = (char*)malloc(iBufMaxSize);
            }
            /* read attr */
            o_NodeSrc.ReadAttr(pcName,uAttrInfo.type,0,
                               (void*)pcBuf,uAttrInfo.size);
            /* write attr */
            o_NodeDest.WriteAttr(pcName,uAttrInfo.type,
                                 0,(void*)pcBuf,uAttrInfo.size);
            /* check for cancel_process */
            if(Canceled()) return false;
        }
    }
    DELETE(pcBuf);
    return true;
}/* end of atributes */
Exemplo n.º 2
0
void
ResView::OpenFile(const entry_ref &ref)
{
	// Add all the 133t resources and attributes of the file
	BFile file(&ref, B_READ_ONLY);
	BResources resources;
	if (resources.SetTo(&file) != B_OK)
		return;
	file.Unset();
	
	resources.PreloadResourceType();
	
	int32 index = 0;
	ResDataRow *row;
	ResourceData *resData = new ResourceData();
	while (resData->SetFromResource(index, resources)) {
		row = new ResDataRow(resData);
		fListView->AddRow(row);
		fDataList.AddItem(resData);
		resData = new ResourceData();
		index++;
	}
	delete resData;

	BNode node;
	if (node.SetTo(&ref) == B_OK) {
		char attrName[B_ATTR_NAME_LENGTH];
		node.RewindAttrs();
		resData = new ResourceData();
		while (node.GetNextAttrName(attrName) == B_OK) {
			if (resData->SetFromAttribute(attrName, node)) {
				row = new ResDataRow(resData);
				fListView->AddRow(row);
				fDataList.AddItem(resData);
				resData = new ResourceData();
			}
		}
		delete resData;
	}
}