예제 #1
0
static int lua_setCurrentDirectory(lua_State *l) {
	if (lua_gettop(l) != 1) return luaL_error(l, "wrong number of arguments");
	const char *path = luaL_checkstring(l, 1);
	if(!path) return luaL_error(l, "Argument error: System.currentDirectory(file) takes a filename as string as argument.");
	lua_getCurrentDirectory(l);
	chdir(path);
	return 1;
}
예제 #2
0
static int lua_setCurrentDirectory(lua_State *L)
{
    const char *path = luaL_checkstring(L, 1);
    if(!path) return luaL_error(L, "System.currentDirectory(file) takes a filename as a string argument.");

    lua_getCurrentDirectory(L);
    chdir(path);

    return 1;
}
예제 #3
0
static int lua_curdir(lua_State *L) {
    int argc = lua_gettop(L);
    if(argc == 0) return lua_getCurrentDirectory(L);
    if(argc == 1) return lua_setCurrentDirectory(L);
    return luaL_error(L, "System.currentDirectory([file]) takes zero or one argument");
}
예제 #4
0
static int lua_curdir(lua_State *l) {
	int argc = lua_gettop(l);
	if(argc == 0) return lua_getCurrentDirectory(l);
	if(argc == 1) return lua_setCurrentDirectory(l);
	return luaL_error(l, "Argument error: System.currentDirectory([file]) takes zero or one argument.");
}