diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d78abaf..e9d70353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All notable changes to this project will be documented in this file. +## Unreleased - ??? +- Add os/umask +- Add os/perm-int +- Add os/perm-str + ## 1.8.1 - 2020-03-31 - Fix bugs for big endian systems - Fix 1.8.0 regression on BSDs diff --git a/src/core/os.c b/src/core/os.c index 7a8162c3..fb1e2c31 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -797,16 +797,6 @@ static Janet os_symlink(int32_t argc, Janet *argv) { #endif } -static Janet os_umask(int32_t argc, Janet *argv) { - janet_fixarity(argc, 1); -#ifdef JANET_WINDOWS - janet_panicf("os/umask not supported on Windows"); -#else - int32_t mask = janet_getinteger(argv, 0); - return janet_wrap_integer(umask(mask)); -#endif -} - static Janet os_mkdir(int32_t argc, Janet *argv) { janet_fixarity(argc, 1); const char *path = janet_getcstring(argv, 0); @@ -1152,6 +1142,17 @@ static Janet os_chmod(int32_t argc, Janet *argv) { return janet_wrap_nil(); } +static Janet os_umask(int32_t argc, Janet *argv) { + janet_fixarity(argc, 1); + int mask = (int) os_getmode(argv, 0); +#ifdef JANET_WINDOWS + int res = _umask(mask); +#else + int res = umask(mask); +#endif + return janet_wrap_integer(janet_perm_to_unix(res)); +} + static Janet os_dir(int32_t argc, Janet *argv) { janet_arity(argc, 1, 2); const char *dir = janet_getcstring(argv, 0);