Zitat:
int fcwd = 0;
char *cwdpath = "";
static int lua_getCurrentDirectory(l ua_State *L)
{
char path[256];
//cwdpath = getcwd(path,256);
lua_pushstring(L, cwdpath);
return 1;
}
static int lua_setCurrentDirectory(l ua_State *L)
{
char *path = luaL_checkstring(L, 1);
if(!path) return luaL_error(L, "Argument error: System.currentDirectory(f ile) takes a filename as string as argument.");
char *ddp = strpbrk (":",path);
if(ddp != NULL)
{
sceIoChdir(path);
chdir(path);
cwdpath = path;
lua_pushstring(L, cwdpath);
return 1;
}
if(strcmp(cwdpath,"ms0:/") == 0)
{
sceIoChdir(path);
chdir(path);
strcat(cwdpath, path);
lua_pushstring(L, cwdpath);
return 1;
}
if(strcmp(cwdpath,"disc0:/") == 0)
{
sceIoChdir(path);
chdir(path);
strcat(cwdpath, path);
lua_pushstring(L, cwdpath);
return 1;
}
sceIoChdir(path);
chdir(path);
strcat(cwdpath, "/");
strcat(cwdpath, path);
lua_getCurrentDirectory(L );
return 1;
}
Regards