Skip to content

Commit 2db8f88

Browse files
committed
Merge pull request godotengine#101125 from axunes/master
macOS: Allow running unpacked game files from .app bundle resources
2 parents a7052a2 + 50b9060 commit 2db8f88

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

core/config/project_settings.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,28 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
648648
return err;
649649
}
650650

651+
#ifdef MACOS_ENABLED
652+
// Attempt to load project file from macOS .app bundle resources.
653+
resource_path = OS::get_singleton()->get_bundle_resource_dir();
654+
if (!resource_path.is_empty()) {
655+
if (resource_path[resource_path.length() - 1] == '/') {
656+
resource_path = resource_path.substr(0, resource_path.length() - 1); // Chop end.
657+
}
658+
Ref<DirAccess> d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
659+
ERR_FAIL_COND_V_MSG(d.is_null(), ERR_CANT_CREATE, vformat("Cannot create DirAccess for path '%s'.", resource_path));
660+
d->change_dir(resource_path);
661+
662+
Error err;
663+
664+
err = _load_settings_text_or_binary(resource_path.path_join("project.godot"), resource_path.path_join("project.binary"));
665+
if (err == OK && !p_ignore_override) {
666+
// Optional, we don't mind if it fails.
667+
_load_settings_text(resource_path.path_join("override.cfg"));
668+
return err;
669+
}
670+
}
671+
#endif
672+
651673
// Nothing was found, try to find a project file in provided path (`p_path`)
652674
// or, if requested (`p_upwards`) in parent directories.
653675

0 commit comments

Comments
 (0)