diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 802ac45..1ce99e9 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -29,6 +29,8 @@ #include "zlib.h" +#include "SDL2/SDL_filesystem.h" + #include #include @@ -65,6 +67,7 @@ void fileIntBindingInit(); static VALUE mriPrint(int, VALUE*, VALUE); static VALUE mriP(int, VALUE*, VALUE); +RB_METHOD(mriDataDirectory); static void mriBindingInit() { @@ -89,6 +92,9 @@ static void mriBindingInit() rb_eval_string(module_rpg); + VALUE mod = rb_define_module("System"); + _rb_define_module_function(mod, "data_directory", mriDataDirectory); + rb_define_global_const("MKXP", Qtrue); } @@ -134,6 +140,23 @@ RB_METHOD(mriP) return Qnil; } +RB_METHOD(mriDataDirectory) +{ + RB_UNUSED_PARAM; + + const char *org, *app; + + rb_get_args(argc, argv, "zz", &org, &app, RB_ARG_END); + + char *path = SDL_GetPrefPath(org, app); + + VALUE pathStr = rb_str_new_cstr(path); + + SDL_free(path); + + return pathStr; +} + static void runCustomScript(const char *filename) { QFile scriptFile(filename);