Rename OS::get_data_dir to OS::get_user_data_dir

Will be needed to avoid confusion with system data path (XDG_DATA_HOME)
and editor data dir in upcoming refactoring.
This commit is contained in:
Rémi Verschelde 2017-11-17 15:25:22 +01:00
parent ebbe2bd572
commit 73049d115e
26 changed files with 53 additions and 53 deletions

View File

@ -888,9 +888,9 @@ void _OS::dump_resources_to_file(const String &p_file) {
OS::get_singleton()->dump_resources_to_file(p_file.utf8().get_data());
}
String _OS::get_data_dir() const {
String _OS::get_user_data_dir() const {
return OS::get_singleton()->get_data_dir();
return OS::get_singleton()->get_user_data_dir();
};
Error _OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
@ -1088,7 +1088,7 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_static_memory_peak_usage"), &_OS::get_static_memory_peak_usage);
ClassDB::bind_method(D_METHOD("get_dynamic_memory_usage"), &_OS::get_dynamic_memory_usage);
ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir);
ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir);
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id);

View File

@ -297,7 +297,7 @@ public:
String get_system_dir(SystemDir p_dir) const;
String get_data_dir() const;
String get_user_data_dir() const;
void alert(const String &p_alert, const String &p_title = "ALERT!");

View File

@ -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);

View File

@ -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);

View File

@ -281,7 +281,7 @@ String OS::get_safe_application_name() const {
return an;
}
String OS::get_data_dir() const {
String OS::get_user_data_dir() const {
return ".";
};
@ -374,9 +374,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);

View File

@ -124,7 +124,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:
@ -334,7 +334,7 @@ public:
virtual String get_locale() const;
String get_safe_application_name() const;
virtual String get_data_dir() const;
virtual String get_user_data_dir() const;
virtual String get_resource_dir() const;
virtual Error move_to_trash(const String &p_path) { return FAILED; }

View File

@ -116,7 +116,7 @@ String ProjectSettings::globalize_path(const String &p_path) const {
return p_path.replace("res://", "");
} else 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("user:/", data_dir);

View File

@ -127,11 +127,11 @@
Returns the current screen index (0 padded).
</description>
</method>
<method name="get_data_dir" qualifiers="const">
<method name="get_user_data_dir" qualifiers="const">
<return type="String">
</return>
<description>
Returns the absolute directory path of user data path([user://]).
Returns the absolute directory path where user data is written ([code]user://[/code]).
</description>
</method>
<method name="get_date" qualifiers="const">

View File

@ -454,7 +454,7 @@ int OS_Unix::get_processor_count() const {
return sysconf(_SC_NPROCESSORS_CONF);
}
String OS_Unix::get_data_dir() const {
String OS_Unix::get_user_data_dir() const {
String an = get_safe_application_name();
if (an != "") {

View File

@ -110,7 +110,7 @@ public:
virtual String get_installed_templates_path() const;
virtual String get_executable_path() const;
virtual String get_data_dir() const;
virtual String get_user_data_dir() const;
//virtual void run( MainLoop * p_main_loop );
};

View File

@ -505,7 +505,7 @@ uint32_t NetworkedMultiplayerENet::_gen_unique_id() const {
hash = hash_djb2_one_32(
(uint32_t)OS::get_singleton()->get_unix_time(), hash);
hash = hash_djb2_one_32(
(uint32_t)OS::get_singleton()->get_data_dir().hash64(), hash);
(uint32_t)OS::get_singleton()->get_user_data_dir().hash64(), hash);
/*
hash = hash_djb2_one_32(
(uint32_t)OS::get_singleton()->get_unique_id().hash64(), hash );

View File

@ -80,7 +80,7 @@ String _get_mono_user_dir() {
return settings_path.plus_file("mono");
}
#else
return OS::get_singleton()->get_data_dir().plus_file("mono");
return OS::get_singleton()->get_user_data_dir().plus_file("mono");
#endif
}

View File

@ -647,7 +647,7 @@ static int _open_uri(const String &p_uri) {
return env->CallIntMethod(godot_io, _openURI, jStr);
}
static String _get_data_dir() {
static String _get_user_data_dir() {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(godot_io, _getDataDir);
@ -825,7 +825,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
AudioDriverAndroid::setup(gob);
}
os_android = new OS_Android(_gfx_init_func, env, _open_uri, _get_data_dir, _get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk, _get_vk_height, _set_screen_orient, _get_unique_id, _get_system_dir, _play_video, _is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, p_use_apk_expansion);
os_android = new OS_Android(_gfx_init_func, env, _open_uri, _get_user_data_dir, _get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk, _get_vk_height, _set_screen_orient, _get_unique_id, _get_system_dir, _play_video, _is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, p_use_apk_expansion);
os_android->set_need_reload_hooks(p_need_reload_hook);
char wd[500];

View File

@ -612,13 +612,13 @@ void OS_Android::set_need_reload_hooks(bool p_needs_them) {
use_reload_hooks = p_needs_them;
}
String OS_Android::get_data_dir() const {
String OS_Android::get_user_data_dir() const {
if (data_dir_cache != String())
return data_dir_cache;
if (get_data_dir_func) {
String data_dir = get_data_dir_func();
if (get_user_data_dir_func) {
String data_dir = get_user_data_dir_func();
//store current dir
char real_current_dir_name[2048];
@ -641,7 +641,6 @@ String OS_Android::get_data_dir() const {
}
return ".";
//return Engine::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
}
void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
@ -709,7 +708,7 @@ bool OS_Android::_check_internal_feature_support(const String &p_feature) {
return p_feature == "mobile" || p_feature == "etc" || p_feature == "etc2"; //TODO support etc2 only if GLES3 driver is selected
}
OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion) {
OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion) {
use_apk_expansion = p_use_apk_expansion;
default_videomode.width = 800;
@ -725,7 +724,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURI
use_gl2 = false;
open_uri_func = p_open_uri_func;
get_data_dir_func = p_get_data_dir_func;
get_user_data_dir_func = p_get_user_data_dir_func;
get_locale_func = p_get_locale_func;
get_model_func = p_get_model_func;
get_screen_dpi_func = p_get_screen_dpi_func;

View File

@ -48,7 +48,7 @@
typedef void (*GFXInitFunc)(void *ud, bool gl2);
typedef int (*OpenURIFunc)(const String &);
typedef String (*GetDataDirFunc)();
typedef String (*GetUserDataDirFunc)();
typedef String (*GetLocaleFunc)();
typedef String (*GetModelFunc)();
typedef int (*GetScreenDPIFunc)();
@ -116,7 +116,7 @@ private:
MainLoop *main_loop;
OpenURIFunc open_uri_func;
GetDataDirFunc get_data_dir_func;
GetUserDataDirFunc get_user_data_dir_func;
GetLocaleFunc get_locale_func;
GetModelFunc get_model_func;
GetScreenDPIFunc get_screen_dpi_func;
@ -208,7 +208,7 @@ public:
virtual void set_screen_orientation(ScreenOrientation p_orientation);
virtual Error shell_open(String p_uri);
virtual String get_data_dir() const;
virtual String get_user_data_dir() const;
virtual String get_resource_dir() const;
virtual String get_locale() const;
virtual String get_model_name() const;
@ -237,7 +237,7 @@ public:
void joy_connection_changed(int p_device, bool p_connected, String p_name);
virtual bool _check_internal_feature_support(const String &p_feature);
OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion);
OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion);
~OS_Android();
};

View File

@ -470,7 +470,7 @@ void OSIPhone::set_cursor_shape(CursorShape p_shape){
};
String OSIPhone::get_data_dir() const {
String OSIPhone::get_user_data_dir() const {
return data_dir;
};
@ -509,7 +509,7 @@ Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
bool exists = f && f->is_open();
String tempFile = get_data_dir();
String tempFile = get_user_data_dir();
if (!exists)
return FAILED;
@ -521,7 +521,7 @@ Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_
p_path = p_path.replace("res:/", ProjectSettings::get_singleton()->get_resource_path());
}
} else if (p_path.begins_with("user://"))
p_path = p_path.replace("user:/", get_data_dir());
p_path = p_path.replace("user:/", get_user_data_dir());
memdelete(f);

View File

@ -178,7 +178,7 @@ public:
Error shell_open(String p_uri);
String get_data_dir() const;
String get_user_data_dir() const;
void set_locale(String p_locale);
String get_locale() const;

View File

@ -889,11 +889,11 @@ String OS_JavaScript::get_resource_dir() const {
return "/"; //javascript has it's own filesystem for resources inside the APK
}
String OS_JavaScript::get_data_dir() const {
String OS_JavaScript::get_user_data_dir() const {
/*
if (get_data_dir_func)
return get_data_dir_func();
if (get_user_data_dir_func)
return get_user_data_dir_func();
*/
return "/userfs";
};
@ -993,7 +993,7 @@ bool OS_JavaScript::is_userfs_persistent() const {
return idbfs_available;
}
OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func) {
OS_JavaScript::OS_JavaScript(const char *p_execpath, GetUserDataDirFunc p_get_user_data_dir_func) {
set_cmdline(p_execpath, get_cmdline_args());
main_loop = NULL;
gl_extensions = NULL;
@ -1001,7 +1001,7 @@ OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_d
soft_fs_enabled = false;
canvas_size_adjustment_requested = false;
get_data_dir_func = p_get_data_dir_func;
get_user_data_dir_func = p_get_user_data_dir_func;
FileAccessUnix::close_notification_func = _close_notification_funcs;
idbfs_available = false;

View File

@ -42,7 +42,7 @@
#include <emscripten/html5.h>
typedef String (*GetDataDirFunc)();
typedef String (*GetUserDataDirFunc)();
class OS_JavaScript : public OS_Unix {
@ -63,7 +63,7 @@ class OS_JavaScript : public OS_Unix {
CursorShape cursor_shape;
MainLoop *main_loop;
GetDataDirFunc get_data_dir_func;
GetUserDataDirFunc get_user_data_dir_func;
PowerJavascript *power_manager;
@ -146,7 +146,7 @@ public:
void set_opengl_extensions(const char *p_gl_extensions);
virtual Error shell_open(String p_uri);
virtual String get_data_dir() const;
virtual String get_user_data_dir() const;
String get_executable_path() const;
virtual String get_resource_dir() const;
@ -165,7 +165,7 @@ public:
void set_idbfs_available(bool p_idbfs_available);
OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func);
OS_JavaScript(const char *p_execpath, GetUserDataDirFunc p_get_user_data_dir_func);
~OS_JavaScript();
};

View File

@ -1095,7 +1095,7 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
power_manager = memnew(power_osx);
_ensure_data_dir();
_ensure_user_data_dir();
restore_rect = Rect2(get_window_position(), get_window_size());
}

View File

@ -73,7 +73,7 @@ void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p
input = memnew(InputDefault);
_ensure_data_dir();
_ensure_user_data_dir();
}
void OS_Server::finalize() {

View File

@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "os_uwp.h"
#include "drivers/gles3/rasterizer_gles3.h"
#include "drivers/unix/ip_unix.h"
#include "drivers/windows/dir_access_windows.h"
@ -298,7 +299,7 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud
ref new TypedEventHandler<Gyrometer ^, GyrometerReadingChangedEventArgs ^>(managed_object, &ManagedType::on_gyroscope_reading_changed);
}
_ensure_data_dir();
_ensure_user_data_dir();
if (is_keep_screen_on())
display_request->RequestActive();
@ -781,7 +782,7 @@ MainLoop *OSUWP::get_main_loop() const {
return main_loop;
}
String OSUWP::get_data_dir() const {
String OSUWP::get_user_data_dir() const {
Windows::Storage::StorageFolder ^ data_folder = Windows::Storage::ApplicationData::Current->LocalFolder;

View File

@ -226,7 +226,7 @@ public:
virtual String get_locale() const;
virtual void move_window_to_foreground();
virtual String get_data_dir() const;
virtual String get_user_data_dir() const;
virtual bool _check_internal_feature_support(const String &p_feature);

View File

@ -1090,7 +1090,7 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
//RegisterTouchWindow(hWnd, 0); // Windows 7
_ensure_data_dir();
_ensure_user_data_dir();
DragAcceptFiles(hWnd, true);
@ -2167,7 +2167,7 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const {
ERR_FAIL_COND_V(res != S_OK, String());
return String(szPath);
}
String OS_Windows::get_data_dir() const {
String OS_Windows::get_user_data_dir() const {
String an = get_safe_application_name();
if (an != "") {

View File

@ -253,7 +253,7 @@ public:
virtual void enable_for_stealing_focus(ProcessID pid);
virtual void move_window_to_foreground();
virtual String get_data_dir() const;
virtual String get_user_data_dir() const;
virtual String get_system_dir(SystemDir p_dir) const;
virtual void release_rendering_thread();

View File

@ -464,7 +464,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
#ifdef JOYDEV_ENABLED
joypad = memnew(JoypadLinux(input));
#endif
_ensure_data_dir();
_ensure_user_data_dir();
power_manager = memnew(PowerX11);
}