summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/os_android.cpp7
-rw-r--r--platform/android/os_android.h1
-rw-r--r--platform/iphone/app_delegate.mm6
-rw-r--r--platform/iphone/godot_iphone.mm4
-rw-r--r--platform/iphone/os_iphone.h5
-rw-r--r--platform/iphone/os_iphone.mm7
-rw-r--r--platform/javascript/api/javascript_tools_editor_plugin.cpp3
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp5
-rw-r--r--platform/windows/display_server_windows.cpp2
-rw-r--r--platform/windows/os_windows.cpp29
10 files changed, 48 insertions, 21 deletions
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 21fb31d991..034885aa32 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -230,10 +230,13 @@ String OS_Android::get_user_data_dir() const {
}
String OS_Android::get_cache_path() const {
+ if (cache_dir_cache != String())
+ return cache_dir_cache;
+
String cache_dir = godot_io_java->get_cache_dir();
if (cache_dir != "") {
- cache_dir = _remove_symlink(cache_dir);
- return cache_dir;
+ cache_dir_cache = _remove_symlink(cache_dir);
+ return cache_dir_cache;
}
return ".";
}
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index c938297821..ce8083388f 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -57,6 +57,7 @@ private:
#endif
mutable String data_dir_cache;
+ mutable String cache_dir_cache;
AudioDriverOpenSL audio_driver_android;
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index d10ea5c68c..c6f91665c5 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -44,7 +44,7 @@
extern int gargc;
extern char **gargv;
-extern int iphone_main(int, char **, String);
+extern int iphone_main(int, char **, String, String);
extern void iphone_finish();
@implementation AppDelegate
@@ -67,8 +67,10 @@ static ViewController *mainViewController = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
+ paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
+ NSString *cacheDirectory = [paths objectAtIndex:0];
- int err = iphone_main(gargc, gargv, String::utf8([documentsDirectory UTF8String]));
+ int err = iphone_main(gargc, gargv, String::utf8([documentsDirectory UTF8String]), String::utf8([cacheDirectory UTF8String]));
if (err != 0) {
// bail, things did not go very well for us, should probably output a message on screen with our error code...
diff --git a/platform/iphone/godot_iphone.mm b/platform/iphone/godot_iphone.mm
index 6c3e1eabde..6f6f9d0708 100644
--- a/platform/iphone/godot_iphone.mm
+++ b/platform/iphone/godot_iphone.mm
@@ -74,7 +74,7 @@ int add_cmdline(int p_argc, char **p_args) {
return p_argc;
};
-int iphone_main(int argc, char **argv, String data_dir) {
+int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
size_t len = strlen(argv[0]);
while (len--) {
@@ -95,7 +95,7 @@ int iphone_main(int argc, char **argv, String data_dir) {
char cwd[512];
getcwd(cwd, sizeof(cwd));
printf("cwd %s\n", cwd);
- os = new OSIPhone(data_dir);
+ os = new OSIPhone(data_dir, cache_dir);
// We must override main when testing is enabled
TEST_MAIN_OVERRIDE
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 248369369d..7a81d8f593 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -72,6 +72,7 @@ private:
virtual void finalize() override;
String user_data_dir;
+ String cache_dir;
bool is_focused = false;
@@ -80,7 +81,7 @@ private:
public:
static OSIPhone *get_singleton();
- OSIPhone(String p_data_dir);
+ OSIPhone(String p_data_dir, String p_cache_dir);
~OSIPhone();
void initialize_modules();
@@ -103,6 +104,8 @@ public:
void set_user_data_dir(String p_dir);
virtual String get_user_data_dir() const override;
+ virtual String get_cache_path() const override;
+
virtual String get_locale() const override;
virtual String get_unique_id() const override;
diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm
index c88d253691..fc07d321b7 100644
--- a/platform/iphone/os_iphone.mm
+++ b/platform/iphone/os_iphone.mm
@@ -87,7 +87,7 @@ OSIPhone *OSIPhone::get_singleton() {
return (OSIPhone *)OS::get_singleton();
}
-OSIPhone::OSIPhone(String p_data_dir) {
+OSIPhone::OSIPhone(String p_data_dir, String p_cache_dir) {
for (int i = 0; i < ios_init_callbacks_count; ++i) {
ios_init_callbacks[i]();
}
@@ -101,6 +101,7 @@ OSIPhone::OSIPhone(String p_data_dir) {
// can't call set_data_dir from here, since it requires DirAccess
// which is initialized in initialize_core
user_data_dir = p_data_dir;
+ cache_dir = p_cache_dir;
Vector<Logger *> loggers;
loggers.push_back(memnew(SyslogLogger));
@@ -266,6 +267,10 @@ String OSIPhone::get_user_data_dir() const {
return user_data_dir;
}
+String OSIPhone::get_cache_path() const {
+ return cache_dir;
+}
+
String OSIPhone::get_locale() const {
NSString *preferedLanguage = [NSLocale preferredLanguages].firstObject;
diff --git a/platform/javascript/api/javascript_tools_editor_plugin.cpp b/platform/javascript/api/javascript_tools_editor_plugin.cpp
index 45a2cd595a..df4c790755 100644
--- a/platform/javascript/api/javascript_tools_editor_plugin.cpp
+++ b/platform/javascript/api/javascript_tools_editor_plugin.cpp
@@ -131,9 +131,10 @@ void JavaScriptToolsEditorPlugin::_zip_recursive(String p_path, String p_base_pa
}
dir->list_dir_begin();
String cur = dir->get_next();
+ String project_data_dir_name = ProjectSettings::get_singleton()->get_project_data_dir_name();
while (!cur.is_empty()) {
String cs = p_path.plus_file(cur);
- if (cur == "." || cur == ".." || cur == ".import") {
+ if (cur == "." || cur == ".." || cur == project_data_dir_name) {
// Skip
} else if (dir->current_is_dir()) {
String path = cs.replace_first(p_base_path, "") + "/";
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 2c9801f512..69474c6dec 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -463,7 +463,10 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
// The trash can is successfully created, now we check that we don't exceed our file name length limit.
// If the file name is too long trim it so we can add the identifying number and ".trashinfo".
// Assumes that the file name length limit is 255 characters.
- String file_name = basename(p_path.utf8().get_data());
+ String file_name = p_path.get_file();
+ if (file_name.length() == 0) {
+ file_name = p_path.get_base_dir().get_file();
+ }
if (file_name.length() > 240) {
file_name = file_name.substr(0, file_name.length() - 15);
}
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 8a946d8136..905c4142a8 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -1208,7 +1208,7 @@ void DisplayServerWindows::cursor_set_shape(CursorShape p_shape) {
IDC_CROSS,
IDC_WAIT,
IDC_APPSTARTING,
- IDC_ARROW,
+ IDC_SIZEALL,
IDC_ARROW,
IDC_NO,
IDC_SIZENS,
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index c03b600f2e..6c02bf1e16 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -677,18 +677,27 @@ String OS_Windows::get_data_path() const {
}
String OS_Windows::get_cache_path() const {
- // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well.
- if (has_environment("XDG_CACHE_HOME")) {
- if (get_environment("XDG_CACHE_HOME").is_absolute_path()) {
- return get_environment("XDG_CACHE_HOME").replace("\\", "/");
- } else {
- WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `%TEMP%` or `get_config_path()` per the XDG Base Directory specification.");
+ static String cache_path_cache;
+ if (cache_path_cache.is_empty()) {
+ // The XDG Base Directory specification technically only applies on Linux/*BSD, but it doesn't hurt to support it on Windows as well.
+ if (has_environment("XDG_CACHE_HOME")) {
+ if (get_environment("XDG_CACHE_HOME").is_absolute_path()) {
+ cache_path_cache = get_environment("XDG_CACHE_HOME").replace("\\", "/");
+ } else {
+ WARN_PRINT_ONCE("`XDG_CACHE_HOME` is a relative path. Ignoring its value and falling back to `%LOCALAPPDATA%\\cache`, `%TEMP%` or `get_config_path()` per the XDG Base Directory specification.");
+ }
+ }
+ if (cache_path_cache.is_empty() && has_environment("LOCALAPPDATA")) {
+ cache_path_cache = get_environment("LOCALAPPDATA").replace("\\", "/");
+ }
+ if (cache_path_cache.is_empty() && has_environment("TEMP")) {
+ cache_path_cache = get_environment("TEMP").replace("\\", "/");
+ }
+ if (cache_path_cache.is_empty()) {
+ cache_path_cache = get_config_path();
}
}
- if (has_environment("TEMP")) {
- return get_environment("TEMP").replace("\\", "/");
- }
- return get_config_path();
+ return cache_path_cache;
}
// Get properly capitalized engine name for system paths