Implement a "Recovery Mode" for recovering crashing/hanging projects during initialization
This commit is contained in:
@ -290,10 +290,28 @@ String OS::get_bundle_icon_path() const {
|
||||
}
|
||||
|
||||
// OS specific path for user://
|
||||
String OS::get_user_data_dir() const {
|
||||
String OS::get_user_data_dir(const String &p_user_dir) const {
|
||||
return ".";
|
||||
}
|
||||
|
||||
String OS::get_user_data_dir() const {
|
||||
String appname = get_safe_dir_name(GLOBAL_GET("application/config/name"));
|
||||
if (!appname.is_empty()) {
|
||||
bool use_custom_dir = GLOBAL_GET("application/config/use_custom_user_dir");
|
||||
if (use_custom_dir) {
|
||||
String custom_dir = get_safe_dir_name(GLOBAL_GET("application/config/custom_user_dir_name"), true);
|
||||
if (custom_dir.is_empty()) {
|
||||
custom_dir = appname;
|
||||
}
|
||||
return get_user_data_dir(custom_dir);
|
||||
} else {
|
||||
return get_user_data_dir(get_godot_dir_name().path_join("app_userdata").path_join(appname));
|
||||
}
|
||||
} else {
|
||||
return get_user_data_dir(get_godot_dir_name().path_join("app_userdata").path_join("[unnamed project]"));
|
||||
}
|
||||
}
|
||||
|
||||
// Absolute path to res://
|
||||
String OS::get_resource_dir() const {
|
||||
return ProjectSettings::get_singleton()->get_resource_path();
|
||||
@ -304,6 +322,23 @@ String OS::get_system_dir(SystemDir p_dir, bool p_shared_storage) const {
|
||||
return ".";
|
||||
}
|
||||
|
||||
void OS::create_lock_file() {
|
||||
if (Engine::get_singleton()->is_recovery_mode_hint()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String lock_file_path = get_user_data_dir().path_join(".recovery_mode_lock");
|
||||
Ref<FileAccess> lock_file = FileAccess::open(lock_file_path, FileAccess::WRITE);
|
||||
if (lock_file.is_valid()) {
|
||||
lock_file->close();
|
||||
}
|
||||
}
|
||||
|
||||
void OS::remove_lock_file() {
|
||||
String lock_file_path = get_user_data_dir().path_join(".recovery_mode_lock");
|
||||
DirAccess::remove_absolute(lock_file_path);
|
||||
}
|
||||
|
||||
Error OS::shell_open(const String &p_uri) {
|
||||
return ERR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user