summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-20 00:42:51 +0100
committerGitHub <noreply@github.com>2017-11-20 00:42:51 +0100
commitecf80fbbbadaa782cbe81a6562916331c6762970 (patch)
tree7a949f6a95f36303a2f2d193aeabd6486e13f4a1 /platform/windows
parentbc26a5bd3a51b11bab63112275e7045c63a0ffc4 (diff)
parent6e3f2f44af808e9f4255c2462e16beee844c0df7 (diff)
Merge pull request #12988 from akien-mga/xdg-home-paths
Add support for XDG Base Directory spec
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/os_windows.cpp57
-rw-r--r--platform/windows/os_windows.h8
2 files changed, 54 insertions, 11 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 97a3198d10..70ac57c7bf 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -47,6 +47,7 @@
#include "servers/visual/visual_server_wrap_mt.h"
#include "stream_peer_winsock.h"
#include "tcp_server_winsock.h"
+#include "version_generated.gen.h"
#include "windows_terminal_logger.h"
#include <process.h>
@@ -1090,7 +1091,7 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
//RegisterTouchWindow(hWnd, 0); // Windows 7
- _ensure_data_dir();
+ _ensure_user_data_dir();
DragAcceptFiles(hWnd, true);
@@ -2131,6 +2132,43 @@ MainLoop *OS_Windows::get_main_loop() const {
return main_loop;
}
+String OS_Windows::get_config_path() const {
+
+ if (has_environment("XDG_CONFIG_HOME")) { // unlikely, but after all why not?
+ return get_environment("XDG_CONFIG_HOME");
+ } else if (has_environment("APPDATA")) {
+ return get_environment("APPDATA");
+ } else {
+ return ".";
+ }
+}
+
+String OS_Windows::get_data_path() const {
+
+ if (has_environment("XDG_DATA_HOME")) {
+ return get_environment("XDG_DATA_HOME");
+ } else {
+ return get_config_path();
+ }
+}
+
+String OS_Windows::get_cache_path() const {
+
+ if (has_environment("XDG_CACHE_HOME")) {
+ return get_environment("XDG_CACHE_HOME");
+ } else if (has_environment("TEMP")) {
+ return get_environment("TEMP");
+ } else {
+ return get_config_path();
+ }
+}
+
+// Get properly capitalized engine name for system paths
+String OS_Windows::get_godot_dir_name() const {
+
+ return String(_MKSTR(VERSION_SHORT_NAME)).capitalize();
+}
+
String OS_Windows::get_system_dir(SystemDir p_dir) const {
int id;
@@ -2167,18 +2205,17 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const {
ERR_FAIL_COND_V(res != S_OK, String());
return String(szPath);
}
-String OS_Windows::get_data_dir() const {
- String an = get_safe_application_name();
- if (an != "") {
+String OS_Windows::get_user_data_dir() const {
- if (has_environment("APPDATA")) {
+ String appname = get_safe_application_name();
+ if (appname != "") {
- bool use_godot = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir");
- if (!use_godot)
- return (OS::get_singleton()->get_environment("APPDATA") + "/" + an).replace("\\", "/");
- else
- return (OS::get_singleton()->get_environment("APPDATA") + "/Godot/app_userdata/" + an).replace("\\", "/");
+ bool use_godot_dir = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir");
+ if (use_godot_dir) {
+ return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname).replace("\\", "/");
+ } else {
+ return get_data_path().plus_file(appname).replace("\\", "/");
}
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index fbd60e5f0d..5e0c240dba 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -253,8 +253,14 @@ public:
virtual void enable_for_stealing_focus(ProcessID pid);
virtual void move_window_to_foreground();
- virtual String get_data_dir() const;
+
+ virtual String get_config_path() const;
+ virtual String get_data_path() const;
+ virtual String get_cache_path() const;
+ virtual String get_godot_dir_name() const;
+
virtual String get_system_dir(SystemDir p_dir) const;
+ virtual String get_user_data_dir() const;
virtual void release_rendering_thread();
virtual void make_rendering_thread();