| 281 | } |
| 282 | |
| 283 | static void PreCreateResources(lua_State* L, const char* path_str, const char** supported_exts, uint32_t num_supported_exts, dmhash_t* canonical_path_hash_out) |
| 284 | { |
| 285 | const char* path_ext = dmResource::GetExtFromPath(path_str); |
| 286 | bool path_ok = false; |
| 287 | if (path_ext) |
| 288 | { |
| 289 | for (uint32_t i = 0; i < num_supported_exts; ++i) |
| 290 | { |
| 291 | const char* ext = supported_exts[i]; |
| 292 | if (dmStrCaseCmp(path_ext, ext) == 0) |
| 293 | { |
| 294 | path_ok = true; |
| 295 | break; |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | if (!path_ok) |
| 301 | { |
| 302 | char message[1024]; |
| 303 | dmSnPrintf(message, sizeof(message), "Unable to create resource, path '%s' must have any of the following extensions: ", path_str); |
| 304 | for (uint32_t i = 0; i < num_supported_exts; ++i) |
| 305 | { |
| 306 | dmStrlCat(message, supported_exts[i], sizeof(message)); |
| 307 | } |
| 308 | luaL_error(L, "%s", message); |
| 309 | } |
| 310 | |
| 311 | dmhash_t canonical_path_hash = GetCanonicalPathHash(path_str); |
| 312 | if (dmResource::FindByHash(g_ResourceModule.m_Factory, canonical_path_hash)) |
| 313 | { |
| 314 | luaL_error(L, "Unable to create resource, a resource is already registered at path '%s'", path_str); |
| 315 | } |
| 316 | |
| 317 | *canonical_path_hash_out = canonical_path_hash; |
| 318 | } |
| 319 | |
| 320 | static void PreCreateResource(lua_State* L, const char* path_str, const char* path_ext_wanted, dmhash_t* canonical_path_hash_out) |
| 321 | { |
no test coverage detected