✨ rootdir function.
parent
1b72ba842c
commit
aacc650741
|
@ -36,6 +36,10 @@ namespace d2
|
||||||
scm_c_define_gsubr("mouse-y", 0, 0, 0,
|
scm_c_define_gsubr("mouse-y", 0, 0, 0,
|
||||||
reinterpret_cast<void*>(&fn_mouse_y));
|
reinterpret_cast<void*>(&fn_mouse_y));
|
||||||
|
|
||||||
|
// Filesystem
|
||||||
|
// ----------
|
||||||
|
scm_c_define_gsubr("rootdir", 0, 0, 1,
|
||||||
|
reinterpret_cast<void*>(&fn_rootdir));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,4 +185,21 @@ namespace d2
|
||||||
{
|
{
|
||||||
return scm_from_int32(Script::game->mouse_y());
|
return scm_from_int32(Script::game->mouse_y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ SCM Script::fn_rootdir(SCM scm_args)
|
||||||
|
{
|
||||||
|
std::filesystem::path path =
|
||||||
|
std::filesystem::current_path();
|
||||||
|
|
||||||
|
size_t sz = scm_to_int32(scm_length(scm_args));
|
||||||
|
|
||||||
|
for (size_t i=0; i<sz; i++)
|
||||||
|
{
|
||||||
|
SCM scm_value = scm_list_ref(scm_args, scm_from_uint64(i));
|
||||||
|
auto value = scm_to_locale_string(scm_value);
|
||||||
|
path = path / value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return scm_from_locale_string(path.string().c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ namespace d2
|
||||||
static SCM fn_mouse_x();
|
static SCM fn_mouse_x();
|
||||||
static SCM fn_mouse_y();
|
static SCM fn_mouse_y();
|
||||||
|
|
||||||
|
static SCM fn_rootdir(SCM scm_args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unique_ptr<Game> game;
|
static std::unique_ptr<Game> game;
|
||||||
static glm::vec4 color;
|
static glm::vec4 color;
|
||||||
|
|
Loading…
Reference in New Issue