Example #1
0
// Gets information about a resource identified by byType and andID.
bool
BResources::GetResourceInfo(type_code byType, int32 andID,
                            const char** nameFound, size_t* lengthFound)
{
    ResourceItem* item = NULL;
    if (InitCheck() == B_OK)
        item = fContainer->ResourceAt(fContainer->IndexOf(byType, andID));
    if (item) {
        if (nameFound)
            *nameFound = item->Name();
        if (lengthFound)
            *lengthFound = item->DataSize();
    }
    return item;
}
Example #2
0
// IndexOf
int32
ResourcesContainer::IndexOf(type_code type, const char *name) const
{
	int32 index = -1;
	int32 count = CountResources();
	for (int32 i = 0; index == -1 && i < count; i++) {
		ResourceItem *item = ResourceAt(i);
		const char *itemName = item->Name();
		if (item->Type() == type && (name == NULL && itemName == NULL
									 || name != NULL && itemName != NULL
										&& !strcmp(name, itemName))) {
			index = i;
		}
	}
	return index;
}
Example #3
0
// Gets information about a resource identified by byPointer.
bool
BResources::GetResourceInfo(const void* byPointer, type_code* typeFound,
                            int32* idFound, size_t* lengthFound, const char** nameFound)
{
    ResourceItem* item = NULL;
    if (InitCheck() == B_OK)
        item = fContainer->ResourceAt(fContainer->IndexOf(byPointer));
    if (item) {
        if (typeFound)
            *typeFound = item->Type();
        if (idFound)
            *idFound = item->ID();
        if (nameFound)
            *nameFound = item->Name();
        if (lengthFound)
            *lengthFound = item->DataSize();
    }
    return item;
}