Add 'System.data_directory()' for save files etc.

Just a small wrapper around SDL2's GetPrefPath()
This commit is contained in:
Jonas Kulla 2013-10-08 06:00:04 +02:00
parent dd25323cdd
commit a108843069
1 changed files with 23 additions and 0 deletions

View File

@ -29,6 +29,8 @@
#include "zlib.h"
#include "SDL2/SDL_filesystem.h"
#include <QFile>
#include <QByteArray>
@ -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);