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

Added ctr.root, close #7, changed the max path length to 1024

ctr.root is not exactly the path to ctruLua.3dsx minus the file name, but is equivalent with HBL and $
(other launchers may work too, and it works perfectly with Citra), and is "romfs:/" if romfs is enabl$
This commit is contained in:
Firew0lf 2016-03-12 23:14:42 +01:00
parent 6a9fbbb133
commit e5467b663d
2 changed files with 19 additions and 3 deletions

View file

@ -3,6 +3,9 @@ The `ctr` module.
@module ctr
@usage local ctr = require("ctr")
*/
#include <stdlib.h>
#include <unistd.h>
#include <3ds/types.h>
#include <3ds/services/apt.h>
#include <3ds/os.h>
@ -202,6 +205,19 @@ int luaopen_ctr_lib(lua_State *L) {
*/
lua_pushstring(L, CTR_BUILD);
lua_setfield(L, -2, "build");
/***
Root directory of ctrµLua. Contains the working directory where ctrµLua has been launched OR the romfs root if romfs has been enabled.
@field root
*/
#ifdef ROMFS
char* buff = "romfs:";
#else
char* buff = malloc(1024);
getcwd(buff, 1024);
#endif
lua_pushstring(L, buff);
lua_setfield(L, -2, "root");
return 1;
}

View file

@ -40,7 +40,7 @@ const char* prefix_path(const char* path) {
char* prefix = "sdmc:";
#endif
char out[256];
char out[1024];
strcpy(out, prefix);
return strcat(out, path);
@ -156,9 +156,9 @@ Get the current working directory.
@treturn string the current working directory
*/
static int fs_getDirectory(lua_State *L) {
char cwd[256];
char cwd[1024];
lua_pushstring(L, getcwd(cwd, 256));
lua_pushstring(L, getcwd(cwd, 1024));
return 1;
}