Ejemplo n.º 1
0
static value_t fl_time_string(value_t *args, uint32_t nargs)
{
    argcount("time.string", nargs, 1);
    double t = todouble(args[0], "time.string");
    char buf[64];
    timestring(t, buf, sizeof(buf));
    return string_from_cstr(buf);
}
Ejemplo n.º 2
0
static value_t fl_path_cwd(value_t *args, uint32_t nargs)
{
    if (nargs > 1)
        argcount("path.cwd", nargs, 1);
    if (nargs == 0) {
        char buf[1024];
        get_cwd(buf, sizeof(buf));
        return string_from_cstr(buf);
    }
    char *ptr = tostring(args[0], "path.cwd");
    if (set_cwd(ptr))
        lerrorf(IOError, "path.cwd: could not cd to %s", ptr);
    return FL_T;
}
Ejemplo n.º 3
0
static value_t fl_path_cwd(value_t *args, uint32_t nargs)
{
    uv_err_t err;
    if (nargs > 1)
        argcount("path.cwd", nargs, 1);
    if (nargs == 0) {
        char buf[1024];
        err = uv_cwd(buf, sizeof(buf));
        if (err.code != UV_OK)
          lerrorf(IOError, "path.cwd: could not get cwd: %s", uv_strerror(err));
        return string_from_cstr(buf);
    }
    char *ptr = tostring(args[0], "path.cwd");
    err = uv_chdir(ptr);
    if (err.code != UV_OK)
        lerrorf(IOError, "path.cwd: could not cd to %s: %s", ptr, uv_strerror(err));
    return FL_T;
}