| 368 | } |
| 369 | |
| 370 | Error GDRESettings::load_dir(const String &p_path) { |
| 371 | Ref<DirAccess> da = DirAccess::open(p_path.get_base_dir()); |
| 372 | ERR_FAIL_COND_V_MSG(da.is_null(), ERR_FILE_CANT_OPEN, "FATAL ERROR: Can't find folder!"); |
| 373 | ERR_FAIL_COND_V_MSG(!da->dir_exists(p_path), ERR_FILE_CANT_OPEN, "FATAL ERROR: Can't find folder!"); |
| 374 | |
| 375 | Error err = GDREPackedData::get_singleton()->add_dir(p_path, false); |
| 376 | if (err != OK) { |
| 377 | ERR_FAIL_V_MSG(err, "FATAL ERROR: Can't open directory!"); |
| 378 | } |
| 379 | // Check for the existence of assets.sparsepck |
| 380 | String sparse_pck_path = p_path.path_join("assets.sparsepck"); |
| 381 | if (FileAccess::exists(sparse_pck_path)) { |
| 382 | for (const auto &pack : packs) { |
| 383 | // skip it, it's already loaded |
| 384 | if (pack->pack_file == sparse_pck_path) { |
| 385 | return OK; |
| 386 | } |
| 387 | } |
| 388 | print_line("Checking if we need to load detected sparse pack..."); |
| 389 | bool needs_load = false; |
| 390 | // We need to check if the project config is encrypted, if so, we need to load it. |
| 391 | if (pack_has_project_config()) { |
| 392 | // only 4.5 and up have these |
| 393 | String proj_config_path = p_path.path_join(has_path_loaded("res://project.binary") ? "project.binary" : "project.godot"); |
| 394 | ProjectConfigLoader pcfg_loader; |
| 395 | if (pcfg_loader.load_cfb(proj_config_path, 4, 5) != OK) { |
| 396 | needs_load = true; |
| 397 | } |
| 398 | } else { |
| 399 | needs_load = true; |
| 400 | } |
| 401 | |
| 402 | if (needs_load) { |
| 403 | print_line("Loading detected sparse pack..."); |
| 404 | err = GDREPackedData::get_singleton()->add_pack(sparse_pck_path, true, 0); |
| 405 | if (err != OK) { |
| 406 | if (error_encryption) { |
| 407 | ERR_FAIL_V_MSG(err, "FATAL ERROR: Can't open detected sparse pack! (Did you set the correct key?)"); |
| 408 | } |
| 409 | ERR_FAIL_V_MSG(err, "FATAL ERROR: Can't open detected sparse pack!"); |
| 410 | } |
| 411 | print_line("Loaded detected sparse pack!"); |
| 412 | } else { |
| 413 | print_line("Skipping loading detected sparse pack..."); |
| 414 | } |
| 415 | } |
| 416 | return OK; |
| 417 | } |
| 418 | |
| 419 | namespace { |
| 420 | bool is_executable(const String &p_path) { |
nothing calls this directly
no test coverage detected