diff --git a/platform/switch/os_switch.cpp b/platform/switch/os_switch.cpp index aeaa5bd38739..c5fd0536f283 100644 --- a/platform/switch/os_switch.cpp +++ b/platform/switch/os_switch.cpp @@ -514,6 +514,27 @@ void OS_Switch::set_executable_path(const char *p_execpath) { switch_execpath = p_execpath; } +String OS_Switch::get_data_path() const { + return "sdmc:/switch"; +} + +String OS_Switch::get_user_data_dir() const { + String appname = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/name")); + if (appname != "") { + bool use_custom_dir = ProjectSettings::get_singleton()->get("application/config/use_custom_user_dir"); + if (use_custom_dir) { + String custom_dir = get_safe_dir_name(ProjectSettings::get_singleton()->get("application/config/custom_user_dir_name"), true); + if (custom_dir == "") { + custom_dir = appname; + } + return get_data_path().plus_file(custom_dir); + } else { + return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname); + } + } + return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file("__unknown"); +} + OS_Switch *OS_Switch::get_singleton() { return (OS_Switch *)OS::get_singleton(); diff --git a/platform/switch/os_switch.h b/platform/switch/os_switch.h index 6d72d8517c5f..9d747dab4006 100644 --- a/platform/switch/os_switch.h +++ b/platform/switch/os_switch.h @@ -82,6 +82,8 @@ class OS_Switch : public OS { virtual String get_executable_path() const; virtual void set_executable_path(const char *p_execpath); + virtual String get_user_data_dir() const; + virtual String get_data_path() const; virtual bool has_environment(const String &p_var) const; virtual String get_environment(const String &p_var) const;