Exemple #1
0
static int rpm_realpath(lua_State *L)
/*@globals fileSystem, internalState @*/
/*@modifies L, fileSystem, internalState @*/
{
    const char *pn;
    char rp_buf[PATH_MAX];
    char *rp = "";

    if (lua_isstring(L, 1))
        pn = lua_tostring(L, 1);
    else {
        (void)luaL_argerror(L, 1, "pathname");
        return 0;
    }
    if ((rp = Realpath(pn, rp_buf)) == NULL) {
        (void)luaL_error(L, "failed to resolve path via realpath(3): %s", strerror(errno));
        return 0;
    }
    lua_pushstring(L, (const char *)rp);
    return 1;
}
Exemple #2
0
static char *Cwd() {
    char buf[PATH_MAX+1];
	char* cwd = getcwd(buf, sizeof(buf));
	if(!cwd) die("getcwd");
	return Realpath(cwd);
};