Provide a getter for the project data directory.
This commit is contained in:
parent
729461b2a4
commit
69f890ff11
18 changed files with 67 additions and 34 deletions
|
|
@ -48,11 +48,22 @@ ProjectSettings *ProjectSettings::get_singleton() {
|
|||
return singleton;
|
||||
}
|
||||
|
||||
String ProjectSettings::get_project_data_dir_name() const {
|
||||
return ".godot";
|
||||
}
|
||||
|
||||
String ProjectSettings::get_project_data_path() const {
|
||||
String project_data_dir_name = get_project_data_dir_name();
|
||||
return "res://" + project_data_dir_name;
|
||||
}
|
||||
|
||||
String ProjectSettings::get_resource_path() const {
|
||||
return resource_path;
|
||||
}
|
||||
|
||||
const String ProjectSettings::IMPORTED_FILES_PATH("res://.godot/imported");
|
||||
String ProjectSettings::get_imported_files_path() const {
|
||||
return get_project_data_path().plus_file("imported");
|
||||
}
|
||||
|
||||
String ProjectSettings::localize_path(const String &p_path) const {
|
||||
if (resource_path == "") {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ class ProjectSettings : public Object {
|
|||
|
||||
public:
|
||||
typedef Map<String, Variant> CustomMap;
|
||||
static const String IMPORTED_FILES_PATH;
|
||||
|
||||
enum {
|
||||
//properties that are not for built in values begin from this value, so builtin ones are displayed first
|
||||
|
|
@ -141,7 +140,10 @@ public:
|
|||
bool property_can_revert(const String &p_name);
|
||||
Variant property_get_revert(const String &p_name);
|
||||
|
||||
String get_project_data_dir_name() const;
|
||||
String get_project_data_path() const;
|
||||
String get_resource_path() const;
|
||||
String get_imported_files_path() const;
|
||||
|
||||
static ProjectSettings *get_singleton();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@
|
|||
#include "core/object/method_bind.h"
|
||||
#include "core/os/os.h"
|
||||
|
||||
const char *NativeExtension::EXTENSION_LIST_CONFIG_FILE = "res://.godot/extension_list.cfg";
|
||||
String NativeExtension::get_extension_list_config_file() {
|
||||
return ProjectSettings::get_singleton()->get_project_data_path().plus_file("extension_list.cfg");
|
||||
}
|
||||
|
||||
class NativeExtensionMethodBind : public MethodBind {
|
||||
GDNativeExtensionClassMethodCall call_func;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
static const char *EXTENSION_LIST_CONFIG_FILE;
|
||||
static String get_extension_list_config_file();
|
||||
|
||||
Error open_library(const String &p_path, const String &p_entry_symbol);
|
||||
void close_library();
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ void NativeExtensionManager::deinitialize_extensions(NativeExtension::Initializa
|
|||
}
|
||||
|
||||
void NativeExtensionManager::load_extensions() {
|
||||
FileAccessRef f = FileAccess::open(NativeExtension::EXTENSION_LIST_CONFIG_FILE, FileAccess::READ);
|
||||
FileAccessRef f = FileAccess::open(NativeExtension::get_extension_list_config_file(), FileAccess::READ);
|
||||
while (f && !f->eof_reached()) {
|
||||
String s = f->get_line().strip_edges();
|
||||
if (s != String()) {
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const St
|
|||
}
|
||||
|
||||
String ResourceFormatImporter::get_import_base_path(const String &p_for_file) const {
|
||||
return ProjectSettings::IMPORTED_FILES_PATH.plus_file(p_for_file.get_file() + "-" + p_for_file.md5_text());
|
||||
return ProjectSettings::get_singleton()->get_imported_files_path().plus_file(p_for_file.get_file() + "-" + p_for_file.md5_text());
|
||||
}
|
||||
|
||||
bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) const {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
/*************************************************************************/
|
||||
|
||||
#include "resource_uid.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/crypto/crypto.h"
|
||||
#include "core/io/dir_access.h"
|
||||
#include "core/io/file_access.h"
|
||||
|
|
@ -36,7 +38,9 @@
|
|||
static constexpr uint32_t char_count = ('z' - 'a');
|
||||
static constexpr uint32_t base = char_count + ('9' - '0');
|
||||
|
||||
const char *ResourceUID::CACHE_FILE = "res://.godot/uid_cache.bin";
|
||||
String ResourceUID::get_cache_file() {
|
||||
return ProjectSettings::get_singleton()->get_project_data_path().plus_file("uid_cache.bin");
|
||||
}
|
||||
|
||||
String ResourceUID::id_to_text(ID p_id) const {
|
||||
if (p_id < 0) {
|
||||
|
|
@ -136,12 +140,13 @@ void ResourceUID::remove_id(ID p_id) {
|
|||
}
|
||||
|
||||
Error ResourceUID::save_to_cache() {
|
||||
if (!FileAccess::exists(CACHE_FILE)) {
|
||||
String cache_file = get_cache_file();
|
||||
if (!FileAccess::exists(cache_file)) {
|
||||
DirAccessRef d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
||||
d->make_dir_recursive(String(CACHE_FILE).get_base_dir()); //ensure base dir exists
|
||||
d->make_dir_recursive(String(cache_file).get_base_dir()); //ensure base dir exists
|
||||
}
|
||||
|
||||
FileAccessRef f = FileAccess::open(CACHE_FILE, FileAccess::WRITE);
|
||||
FileAccessRef f = FileAccess::open(cache_file, FileAccess::WRITE);
|
||||
if (!f) {
|
||||
return ERR_CANT_OPEN;
|
||||
}
|
||||
|
|
@ -165,7 +170,7 @@ Error ResourceUID::save_to_cache() {
|
|||
}
|
||||
|
||||
Error ResourceUID::load_from_cache() {
|
||||
FileAccessRef f = FileAccess::open(CACHE_FILE, FileAccess::READ);
|
||||
FileAccessRef f = FileAccess::open(get_cache_file(), FileAccess::READ);
|
||||
if (!f) {
|
||||
return ERR_CANT_OPEN;
|
||||
}
|
||||
|
|
@ -207,7 +212,7 @@ Error ResourceUID::update_cache() {
|
|||
for (OrderedHashMap<ID, Cache>::Element E = unique_ids.front(); E; E = E.next()) {
|
||||
if (!E.get().saved_to_cache) {
|
||||
if (f == nullptr) {
|
||||
f = FileAccess::open(CACHE_FILE, FileAccess::READ_WRITE); //append
|
||||
f = FileAccess::open(get_cache_file(), FileAccess::READ_WRITE); //append
|
||||
if (!f) {
|
||||
return ERR_CANT_OPEN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public:
|
|||
INVALID_ID = -1
|
||||
};
|
||||
|
||||
static const char *CACHE_FILE;
|
||||
static String get_cache_file();
|
||||
|
||||
private:
|
||||
mutable Ref<Crypto> crypto;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue