summaryrefslogtreecommitdiff
path: root/core/os/os.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-11-17 17:11:41 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-11-19 20:54:24 +0100
commit32c12a92a5633678921ee9e43f72eb3b59a635ed (patch)
tree17170a81fb6e47ee189a8bb86ff58a691e7ab142 /core/os/os.cpp
parentad199c396478a7165da1eb6909ccb28f124b0240 (diff)
Add initial support for the XDG Base Directory spec
Spec version 0.7 from https://standards.freedesktop.org/basedir-spec/basedir-spec-0.7.html (latest as of this commit). Three virtual methods are added to OS for the various XDG paths we will use: - OS::get_data_path gives XDG_DATA_HOME, or if missing: ~/.local/share on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows - OS::get_config_path gives XDG_CONFIG_HOME, or if missing: ~/.config on X11, ~/Library/Application Support/ on macOS and %APPDATA% on Windows - OS::get_cache_path gives XDG_CACHE_HOME, or if missing: ~/.cache on X11, ~/Library/Caches on macOS and %APPDATA% on Windows So for Windows there are no changes, for Linux we follow the full split spec and for macOS stuff will move from ~/.godot to ~/Library/Application Support/Godot. Support for system-wide installation of templates on Unix was removed for now, as it's a bit hackish and I don't think anyone uses it. user:// will still be OS::get_data_path() + "/godot/app_userdata/$name" by default, but when using the application/config/use_shared_user_dir option it will now use XDG_DATA_HOME/$name, e.g. ~/.local/share/MyGame. For now everything still goes in EditorSettings::get_settings_dir(), but this will be changed in a later commit to make use of the new splitting where relevant. Part of #3513.
Diffstat (limited to 'core/os/os.cpp')
-rw-r--r--core/os/os.cpp52
1 files changed, 42 insertions, 10 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp
index ea0f5de8bd..8d050c1c4c 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -33,6 +33,7 @@
#include "input.h"
#include "os/file_access.h"
#include "project_settings.h"
+#include "version_generated.gen.h"
#include <stdarg.h>
@@ -262,16 +263,7 @@ String OS::get_locale() const {
return "en";
}
-String OS::get_resource_dir() const {
-
- return ProjectSettings::get_singleton()->get_resource_path();
-}
-
-String OS::get_system_dir(SystemDir p_dir) const {
-
- return ".";
-}
-
+// Helper function used by OS_Unix and OS_Windows
String OS::get_safe_application_name() const {
String an = ProjectSettings::get_singleton()->get("application/config/name");
Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" ");
@@ -281,11 +273,51 @@ String OS::get_safe_application_name() const {
return an;
}
+// Path to data, config, cache, etc. OS-specific folders
+
+// Get properly capitalized engine name for system paths
+String OS::get_godot_dir_name() const {
+
+ // Default to lowercase, so only override when different case is needed
+ return String(_MKSTR(VERSION_SHORT_NAME)).to_lower();
+}
+
+// OS equivalent of XDG_DATA_HOME
+String OS::get_data_path() const {
+
+ return ".";
+}
+
+// OS equivalent of XDG_CONFIG_HOME
+String OS::get_config_path() const {
+
+ return ".";
+}
+
+// OS equivalent of XDG_CACHE_HOME
+String OS::get_cache_path() const {
+
+ return ".";
+}
+
+// OS specific path for user://
String OS::get_user_data_dir() const {
return ".";
};
+// Absolute path to res://
+String OS::get_resource_dir() const {
+
+ return ProjectSettings::get_singleton()->get_resource_path();
+}
+
+// Access system-specific dirs like Documents, Downloads, etc.
+String OS::get_system_dir(SystemDir p_dir) const {
+
+ return ".";
+}
+
Error OS::shell_open(String p_uri) {
return ERR_UNAVAILABLE;
};