void ResourcesContainer::AssimilateResources(ResourcesContainer &container) { // Resistance is futile! ;-) int32 newCount = container.CountResources(); for (int32 i = 0; i < newCount; i++) { ResourceItem *item = container.ResourceAt(i); if (item->IsLoaded()) AddResource(item); else { // That should not happen. // Delete the item to have a consistent behavior. delete item; } } container.fResources.MakeEmpty(); container.SetModified(true); SetModified(true); }
// Loads a resource identified by type and name into memory. const void* BResources::LoadResource(type_code type, const char* name, size_t* _size) { // find the resource status_t error = InitCheck(); ResourceItem* resource = NULL; if (error == B_OK) { resource = fContainer->ResourceAt(fContainer->IndexOf(type, name)); if (!resource) error = B_ENTRY_NOT_FOUND; } // load it, if necessary if (error == B_OK && !resource->IsLoaded() && fResourceFile) error = fResourceFile->ReadResource(*resource); // return the result const void* result = NULL; if (error == B_OK) { result = resource->Data(); if (_size) *_size = resource->DataSize(); } return result; }