From 6d2f985db494432e6d5194d5f7c2c00e7f099c55 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 29 Apr 2017 17:56:51 +0200 Subject: Revert "Use .godot as file extension for project files." --- core/global_config.cpp | 72 ++++++++++---------------------------------------- core/global_config.h | 3 --- 2 files changed, 14 insertions(+), 61 deletions(-) (limited to 'core') diff --git a/core/global_config.cpp b/core/global_config.cpp index f9a0877c23..5ce9a088b8 100644 --- a/core/global_config.cpp +++ b/core/global_config.cpp @@ -53,11 +53,6 @@ String GlobalConfig::get_resource_path() const { return resource_path; }; -String GlobalConfig::get_project_file_name() const { - - return project_file_name; -} - String GlobalConfig::localize_path(const String &p_path) const { if (resource_path == "") @@ -241,43 +236,13 @@ bool GlobalConfig::_load_resource_pack(const String &p_pack) { return true; } -static String _find_project_file(DirAccess *p_diraccess, bool p_res = false) { - p_diraccess->list_dir_begin(); - String ret = ""; - while (true) { - bool isdir; - String file = p_diraccess->get_next(&isdir); - if (file == "") - break; - - if (!isdir) { - if (file.get_extension() == "godot") { - - if (p_res) { - ret = "res://" + file; - } else { - ret = p_diraccess->get_current_dir() + "/" + file; - } - } - } - } - p_diraccess->list_dir_end(); - return ret; -} - -static String _find_project_file() { - DirAccess *dir = DirAccess::create(DirAccess::ACCESS_RESOURCES); - String ret = _find_project_file(dir, true); - memdelete(dir); - return ret; -} - Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { //If looking for files in network, just use network! + if (FileAccessNetworkClient::get_singleton()) { - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } @@ -293,8 +258,8 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { bool ok = _load_resource_pack(p_main_pack); ERR_FAIL_COND_V(!ok, ERR_CANT_OPEN); - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { //load override from location of the main pack _load_settings(p_main_pack.get_base_dir().plus_file("override.cfg")); } @@ -307,8 +272,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { if (_load_resource_pack(exec_path.get_basename() + ".pck")) { - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { //load override from location of executable _load_settings(exec_path.get_base_dir().plus_file("override.cfg")); } @@ -328,15 +292,15 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { // data.pck and data.zip are deprecated and no longer supported, apologies. // make sure this is loaded from the resource path - String gdproj = _find_project_file(); - if (_load_settings(gdproj) == OK || _load_settings_binary("res://godot.cfb") == OK) { + + if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } return OK; } - //Nothing was found, try to find a *.godot somewhere! + //Nothing was found, try to find a godot.cfg somewhere! DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_FAIL_COND_V(!d, ERR_CANT_CREATE); @@ -349,8 +313,8 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { while (true) { //try to load settings in ascending through dirs shape! - String gdproj = _find_project_file(d); - if (_load_settings(gdproj) == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { + + if (_load_settings(current_dir + "/godot.cfg") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { _load_settings(current_dir + "/override.cfg"); candidate = current_dir; @@ -464,7 +428,6 @@ Error GlobalConfig::_load_settings(const String p_path) { err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); if (err == ERR_FILE_EOF) { memdelete(f); - project_file_name = p_path.get_file(); return OK; } else if (err != OK) { ERR_PRINTS("GlobalConfig::load - " + p_path + ":" + itos(lines) + " error: " + error_text); @@ -486,7 +449,6 @@ Error GlobalConfig::_load_settings(const String p_path) { } } - project_file_name = p_path.get_file(); memdelete(f); return OK; @@ -512,12 +474,7 @@ void GlobalConfig::clear(const String &p_name) { Error GlobalConfig::save() { - if (project_file_name.empty()) { - String name = ((String)get("application/name")).replace(" ", "_"); - return save_custom(get_resource_path() + "/" + name + ".godot"); - } else { - return save_custom(get_resource_path() + "/" + project_file_name); - } + return save_custom(get_resource_path() + "/godot.cfg"); } Error GlobalConfig::_save_settings_binary(const String &p_file, const Map > &props, const CustomMap &p_custom) { @@ -526,7 +483,7 @@ Error GlobalConfig::_save_settings_binary(const String &p_file, const Map