Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user directory access #24

Merged
merged 1 commit into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions platform/switch/os_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions platform/switch/os_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down