1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Updated font and fs lib; updated editor; updated sf2dlib

Libs additions: font.load, font:unload, font:getWidth, fs.getDirectory, fs.setDirectory, fs.exists

Editor additions: syntaxic coloring and mono font

sf2dlib update: you will need the latest version of ctrulib.

Also, because of the lib font needs, the sftdlib was modified.
This commit is contained in:
Reuh 2015-09-05 19:00:36 +02:00
parent 3f995629c0
commit 45f3216ed8
14 changed files with 382 additions and 28 deletions

View file

@ -1,3 +1,5 @@
#include <unistd.h>
#include <3ds/types.h>
#include <3ds/util/utf.h>
#include <3ds/services/fs.h>
@ -8,7 +10,7 @@
Handle *fsuHandle;
FS_archive sdmcArchive;
int fs_list(lua_State *L) {
static int fs_list(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
lua_newtable(L);
@ -60,8 +62,40 @@ int fs_list(lua_State *L) {
return 1;
}
static int fs_exists(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
lua_pushboolean(L, access(path, F_OK) == 0);
return 1;
}
static int fs_getDirectory(lua_State *L) {
char cwd[256];
lua_pushstring(L, getcwd(cwd, 256));
return 1;
}
static int fs_setDirectory(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
int result = chdir(path);
if (result == 0)
lua_pushboolean(L, true);
else
lua_pushboolean(L, false);
return 1;
}
static const struct luaL_Reg fs_lib[] = {
{ "list", fs_list },
{ "list", fs_list },
{ "exists", fs_exists },
{ "getDirectory", fs_getDirectory },
{ "setDirectory", fs_setDirectory },
{ NULL, NULL }
};