summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/os')
-rw-r--r--core/os/dir_access.cpp4
-rw-r--r--core/os/file_access.cpp2
-rw-r--r--core/os/memory.cpp20
-rw-r--r--core/os/memory.h8
-rw-r--r--core/os/os.cpp58
-rw-r--r--core/os/os.h19
6 files changed, 89 insertions, 22 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 0875f78478..35e4443f2a 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -38,7 +38,7 @@ String DirAccess::_get_root_path() const {
switch (_access_type) {
case ACCESS_RESOURCES: return ProjectSettings::get_singleton()->get_resource_path();
- case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir();
+ case ACCESS_USERDATA: return OS::get_singleton()->get_user_data_dir();
default: return "";
}
@@ -217,7 +217,7 @@ String DirAccess::fix_path(String p_path) const {
if (p_path.begins_with("user://")) {
- String data_dir = OS::get_singleton()->get_data_dir();
+ String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
return p_path.replace_first("user:/", data_dir);
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index fcb3b58fed..5fdd2b9135 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -152,7 +152,7 @@ String FileAccess::fix_path(const String &p_path) const {
if (r_path.begins_with("user://")) {
- String data_dir = OS::get_singleton()->get_data_dir();
+ String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
return r_path.replace("user:/", data_dir);
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index 74d5cbbea1..439951f711 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -44,6 +44,26 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)) {
return p_allocfunc(p_size);
}
+#ifdef _MSC_VER
+void operator delete(void *p_mem, const char *p_description) {
+
+ ERR_EXPLAINC("Call to placement delete should not happen.");
+ CRASH_NOW();
+}
+
+void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)) {
+
+ ERR_EXPLAINC("Call to placement delete should not happen.");
+ CRASH_NOW();
+}
+
+void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description) {
+
+ ERR_EXPLAINC("Call to placement delete should not happen.");
+ CRASH_NOW();
+}
+#endif
+
#ifdef DEBUG_ENABLED
uint64_t Memory::mem_usage = 0;
uint64_t Memory::max_usage = 0;
diff --git a/core/os/memory.h b/core/os/memory.h
index f8b3da579b..7801d56837 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -72,6 +72,14 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< ope
void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description); ///< operator new that takes a description and uses a pointer to the preallocated memory
+#ifdef _MSC_VER
+// When compiling with VC++ 2017, the above declarations of placement new generate many irrelevant warnings (C4291).
+// The purpose of the following definitions is to muffle these warnings, not to provide a usable implementation of placement delete.
+void operator delete(void *p_mem, const char *p_description);
+void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size));
+void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description);
+#endif
+
#define memalloc(m_size) Memory::alloc_static(m_size)
#define memrealloc(m_mem, m_size) Memory::realloc_static(m_mem, m_size)
#define memfree(m_size) Memory::free_static(m_size)
diff --git a/core/os/os.cpp b/core/os/os.cpp
index eb5d5be33d..65d0b2e05d 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;
}
-String OS::get_data_dir() const {
+// 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(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;
};
@@ -374,9 +406,9 @@ OS::ScreenOrientation OS::get_screen_orientation() const {
return (OS::ScreenOrientation)_orientation;
}
-void OS::_ensure_data_dir() {
+void OS::_ensure_user_data_dir() {
- String dd = get_data_dir();
+ String dd = get_user_data_dir();
DirAccess *da = DirAccess::open(dd);
if (da) {
memdelete(da);
diff --git a/core/os/os.h b/core/os/os.h
index faecdb0e07..e48e5c6d70 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -90,13 +90,15 @@ public:
bool fullscreen;
bool resizable;
bool borderless_window;
+ bool maximized;
float get_aspect() const { return (float)width / (float)height; }
- VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false) {
+ VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false) {
width = p_width;
height = p_height;
fullscreen = p_fullscreen;
resizable = p_resizable;
borderless_window = p_borderless_window;
+ maximized = p_maximized;
}
};
@@ -124,7 +126,7 @@ protected:
virtual void set_cmdline(const char *p_execpath, const List<String> &p_args);
- void _ensure_data_dir();
+ void _ensure_user_data_dir();
virtual bool _check_internal_feature_support(const String &p_feature) = 0;
public:
@@ -200,7 +202,6 @@ public:
virtual void set_low_processor_usage_mode(bool p_enabled);
virtual bool is_in_low_processor_usage_mode() const;
- virtual String get_installed_templates_path() const { return ""; }
virtual String get_executable_path() const;
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0;
virtual Error kill(const ProcessID &p_pid) = 0;
@@ -334,10 +335,14 @@ public:
virtual String get_locale() const;
String get_safe_application_name() const;
- virtual String get_data_dir() const;
- virtual String get_resource_dir() const;
+ virtual String get_godot_dir_name() const;
- virtual Error move_to_trash(const String &p_path) { return FAILED; }
+ virtual String get_data_path() const;
+ virtual String get_config_path() const;
+ virtual String get_cache_path() const;
+
+ virtual String get_user_data_dir() const;
+ virtual String get_resource_dir() const;
enum SystemDir {
SYSTEM_DIR_DESKTOP,
@@ -352,6 +357,8 @@ public:
virtual String get_system_dir(SystemDir p_dir) const;
+ virtual Error move_to_trash(const String &p_path) { return FAILED; }
+
virtual void set_no_window_mode(bool p_enable);
virtual bool is_no_window_mode_enabled() const;