예제 #1
0
파일: Project.cpp 프로젝트: passick/Paladin
bool
ResourceToAttribute(BFile &file, BResources &res,type_code code, const char *name)
{
	if (!name)
		return false;
	
	int32 id;
	size_t length;
	if (res.GetResourceInfo(code,name,&id,&length))
	{
		const void *buffer = res.LoadResource(code,name,&length);
		if (!buffer)
		{
			STRACE(2,("Resource %s exists, but couldn't be loaded\n",name));
			return false;
		}
		file.WriteAttr(name,code,0,buffer,length);
		STRACE(2,("Successfully wrote attribute %s\n",name));
		return true;
	}
	else
	{
		STRACE(2,("Resource %s doesn't exist\n",name));
	}
	return false;
}
예제 #2
0
bool
ResourceData::SetFromResource(const int32 &index, BResources &res)
{
	char *name;
	if (!res.GetResourceInfo(index, (type_code*)&fType, &fID,
							(const char **)&name, &fLength)) {
		*this = ResourceData();
		return false;
	}
	fName = name;
	fTypeString = MakeTypeString(fType);
	fIDString = "";
	fIDString << fID;
	fAttr = false;
	char *data = (char *)res.LoadResource(fType,fID,&fLength);
	SetData(data,fLength);
	
	return true;
}