| 1030 | } |
| 1031 | |
| 1032 | Result InsertResource(HFactory factory, const char* path, uint64_t canonical_path_hash, ResourceDescriptor* descriptor) |
| 1033 | { |
| 1034 | if (factory->m_Resources->Full()) |
| 1035 | { |
| 1036 | dmLogError("The max number of resources (%d) has been passed, tweak \"%s\" in the config file.", factory->m_Resources->Capacity(), MAX_RESOURCES_KEY); |
| 1037 | return RESULT_OUT_OF_RESOURCES; |
| 1038 | } |
| 1039 | |
| 1040 | assert(descriptor->m_Resource); |
| 1041 | assert(descriptor->m_ReferenceCount == 1); |
| 1042 | |
| 1043 | factory->m_Resources->Put(canonical_path_hash, *descriptor); |
| 1044 | factory->m_ResourceToHash->Put((uintptr_t) descriptor->m_Resource, canonical_path_hash); |
| 1045 | if (factory->m_ResourceHashToFilename) |
| 1046 | { |
| 1047 | char canonical_path[RESOURCE_PATH_MAX]; |
| 1048 | GetCanonicalPath(path, canonical_path, sizeof(canonical_path)); |
| 1049 | factory->m_ResourceHashToFilename->Put(canonical_path_hash, strdup(canonical_path)); |
| 1050 | } |
| 1051 | |
| 1052 | descriptor->m_Version = IncreaseVersion(factory); |
| 1053 | |
| 1054 | return RESULT_OK; |
| 1055 | } |
| 1056 | |
| 1057 | Result GetRaw(HFactory factory, const char* name, void** resource, uint32_t* resource_size) |
| 1058 | { |
no test coverage detected