1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 01:37:19 +00:00

Add umask support for windows, and allow parsing mode strings.

This commit is contained in:
Calvin Rose 2020-04-03 15:12:58 -05:00
parent edb2fab64c
commit 95f1ef7561
2 changed files with 16 additions and 10 deletions

View File

@ -1,6 +1,11 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. 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 ## 1.8.1 - 2020-03-31
- Fix bugs for big endian systems - Fix bugs for big endian systems
- Fix 1.8.0 regression on BSDs - Fix 1.8.0 regression on BSDs

View File

@ -797,16 +797,6 @@ static Janet os_symlink(int32_t argc, Janet *argv) {
#endif #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) { static Janet os_mkdir(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1); janet_fixarity(argc, 1);
const char *path = janet_getcstring(argv, 0); const char *path = janet_getcstring(argv, 0);
@ -1152,6 +1142,17 @@ static Janet os_chmod(int32_t argc, Janet *argv) {
return janet_wrap_nil(); 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) { static Janet os_dir(int32_t argc, Janet *argv) {
janet_arity(argc, 1, 2); janet_arity(argc, 1, 2);
const char *dir = janet_getcstring(argv, 0); const char *dir = janet_getcstring(argv, 0);