diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/keyboard.cpp | 3 | ||||
-rw-r--r-- | core/os/keyboard.h | 5 | ||||
-rw-r--r-- | core/os/os.cpp | 16 | ||||
-rw-r--r-- | core/os/os.h | 5 |
4 files changed, 24 insertions, 5 deletions
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index e0231b818f..5183b77cb1 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -63,12 +63,15 @@ static const _KeyCodeText _keycodes[] = { {Key::CTRL ,"Ctrl"}, #if defined(MACOS_ENABLED) {Key::META ,"Command"}, + {Key::CMD_OR_CTRL ,"Command"}, {Key::ALT ,"Option"}, #elif defined(WINDOWS_ENABLED) {Key::META ,"Windows"}, + {Key::CMD_OR_CTRL ,"Ctrl"}, {Key::ALT ,"Alt"}, #else {Key::META ,"Meta"}, + {Key::CMD_OR_CTRL ,"Ctrl"}, {Key::ALT ,"Alt"}, #endif {Key::CAPSLOCK ,"CapsLock"}, diff --git a/core/os/keyboard.h b/core/os/keyboard.h index 389baee915..c78fa2a631 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -65,6 +65,11 @@ enum class Key { SHIFT = SPECIAL | 0x15, CTRL = SPECIAL | 0x16, META = SPECIAL | 0x17, +#if defined(MACOS_ENABLED) + CMD_OR_CTRL = META, +#else + CMD_OR_CTRL = CTRL, +#endif ALT = SPECIAL | 0x18, CAPSLOCK = SPECIAL | 0x19, NUMLOCK = SPECIAL | 0x1A, diff --git a/core/os/os.cpp b/core/os/os.cpp index c6fa8d307b..86469852e3 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -203,16 +203,26 @@ uint64_t OS::get_embedded_pck_offset() const { } // Helper function to ensure that a dir name/path will be valid on the OS -String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator) const { +String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const { + String safe_dir_name = p_dir_name; Vector<String> invalid_chars = String(": * ? \" < > |").split(" "); - if (p_allow_dir_separator) { + if (p_allow_paths) { // Dir separators are allowed, but disallow ".." to avoid going up the filesystem invalid_chars.push_back(".."); + safe_dir_name = safe_dir_name.replace("\\", "/").strip_edges(); } else { invalid_chars.push_back("/"); + invalid_chars.push_back("\\"); + safe_dir_name = safe_dir_name.strip_edges(); + + // These directory names are invalid. + if (safe_dir_name == ".") { + safe_dir_name = "dot"; + } else if (safe_dir_name == "..") { + safe_dir_name = "twodots"; + } } - String safe_dir_name = p_dir_name.replace("\\", "/").strip_edges(); for (int i = 0; i < invalid_chars.size(); i++) { safe_dir_name = safe_dir_name.replace(invalid_chars[i], "-"); } diff --git a/core/os/os.h b/core/os/os.h index b80efa47b7..436a83eae3 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -167,7 +167,8 @@ public: virtual bool has_environment(const String &p_var) const = 0; virtual String get_environment(const String &p_var) const = 0; - virtual bool set_environment(const String &p_var, const String &p_value) const = 0; + virtual void set_environment(const String &p_var, const String &p_value) const = 0; + virtual void unset_environment(const String &p_var) const = 0; virtual String get_name() const = 0; virtual String get_distribution_name() const = 0; @@ -237,7 +238,7 @@ public: virtual uint64_t get_embedded_pck_offset() const; - String get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator = false) const; + String get_safe_dir_name(const String &p_dir_name, bool p_allow_paths = false) const; virtual String get_godot_dir_name() const; virtual String get_data_path() const; |