Add getcwd(3)

This commit is contained in:
Michael Santos
2014-03-02 14:36:41 -05:00
parent 184c103e12
commit fc72f1ad7d
3 changed files with 17 additions and 0 deletions

View File

@@ -254,6 +254,7 @@ specs() ->
-spec chdir(port(),iodata()) -> 'ok' | {'error', file:posix()}.
-spec chroot(port(),iodata()) -> 'ok' | {'error', file:posix()}.
-spec execvp(port(),iodata(),iodata()) -> 'ok'.
-spec getcwd(port()) -> {'ok', binary()} | {'error', file:posix()}.
-spec getgid(port()) -> non_neg_integer().
-spec getrlimit(port(),non_neg_integer()) -> {'ok', #rlimit{}} | {'error', file:posix()}.
-spec getuid(port()) -> non_neg_integer().

View File

@@ -170,6 +170,21 @@ BADARG:
return erl_mk_atom("badarg");
}
/*
* getcwd(3)
*
*/
static ETERM *
alcove_getcwd(ETERM *arg)
{
char buf[PATH_MAX] = {0};
if (!getcwd(buf, sizeof(buf)))
return alcove_errno(errno);
return alcove_ok(erl_mk_binary(buf, strlen(buf)));
}
/*
* getgid(2)
*

View File

@@ -1,6 +1,7 @@
chdir/1
chroot/1
execvp/2
getcwd/0
getgid/0
getrlimit/1
getuid/0