1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Add NO_UMASK and NO_REALPATH config options.

This commit is contained in:
Calvin Rose 2020-05-10 23:07:54 -05:00
parent e013381e72
commit 3100080a50
4 changed files with 20 additions and 2 deletions

View File

@ -1,6 +1,9 @@
# 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 - ???
- Fix compilation issue when nanboxing is disabled.
## 1.9.0 - 2020-05-10 ## 1.9.0 - 2020-05-10
- Add `:ldflags` option to many jpm declare functions. - Add `:ldflags` option to many jpm declare functions.
- Add `errorf` to core. - Add `errorf` to core.

View File

@ -55,7 +55,9 @@
/* Other settings */ /* Other settings */
/* #define JANET_NO_PRF */ /* #define JANET_NO_PRF */
/* #define JANET_NO_UTC_MKTIME */ /* #define JANET_NO_UTC_MKTIME */
/* #define JANET_NO_REALPATH */
/* #define JANET_NO_SYMLINKS */ /* #define JANET_NO_SYMLINKS */
/* #define JANET_NO_UMASK */
/* #define JANET_OUT_OF_MEMORY do { printf("janet out of memory\n"); exit(1); } while (0) */ /* #define JANET_OUT_OF_MEMORY do { printf("janet out of memory\n"); exit(1); } while (0) */
/* #define JANET_EXIT(msg) do { printf("C assert failed executing janet: %s\n", msg); exit(1); } while (0) */ /* #define JANET_EXIT(msg) do { printf("C assert failed executing janet: %s\n", msg); exit(1); } while (0) */
/* #define JANET_TOP_LEVEL_SIGNAL(msg) call_my_function((msg), stderr) */ /* #define JANET_TOP_LEVEL_SIGNAL(msg) call_my_function((msg), stderr) */

View File

@ -877,6 +877,7 @@ static Janet os_remove(int32_t argc, Janet *argv) {
return janet_wrap_nil(); return janet_wrap_nil();
} }
#ifndef JANET_NO_SYMLINKS
static Janet os_readlink(int32_t argc, Janet *argv) { static Janet os_readlink(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1); janet_fixarity(argc, 1);
#ifdef JANET_WINDOWS #ifdef JANET_WINDOWS
@ -893,6 +894,7 @@ static Janet os_readlink(int32_t argc, Janet *argv) {
return janet_stringv((const uint8_t *)buffer, len); return janet_stringv((const uint8_t *)buffer, len);
#endif #endif
} }
#endif
#ifdef JANET_WINDOWS #ifdef JANET_WINDOWS
@ -1161,6 +1163,7 @@ static Janet os_chmod(int32_t argc, Janet *argv) {
return janet_wrap_nil(); return janet_wrap_nil();
} }
#ifndef JANET_NO_UMASK
static Janet os_umask(int32_t argc, Janet *argv) { static Janet os_umask(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1); janet_fixarity(argc, 1);
int mask = (int) os_getmode(argv, 0); int mask = (int) os_getmode(argv, 0);
@ -1171,6 +1174,7 @@ static Janet os_umask(int32_t argc, Janet *argv) {
#endif #endif
return janet_wrap_integer(janet_perm_to_unix(res)); return janet_wrap_integer(janet_perm_to_unix(res));
} }
#endif
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);
@ -1220,9 +1224,9 @@ static Janet os_rename(int32_t argc, Janet *argv) {
static Janet os_realpath(int32_t argc, Janet *argv) { static Janet os_realpath(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1); janet_fixarity(argc, 1);
#ifdef JANET_WINDOWS #ifdef JANET_NO_REALPATH
(void) argv; (void) argv;
janet_panic("os/realpath not supported on Windows"); janet_panic("os/realpath not supported on this platform");
#else #else
const char *src = janet_getcstring(argv, 0); const char *src = janet_getcstring(argv, 0);
char *dest = realpath(src, NULL); char *dest = realpath(src, NULL);
@ -1339,11 +1343,13 @@ static const JanetReg os_cfuns[] = {
JDOC("(os/cd path)\n\n" JDOC("(os/cd path)\n\n"
"Change current directory to path. Returns nil on success, errors on failure.") "Change current directory to path. Returns nil on success, errors on failure.")
}, },
#ifndef JANET_NO_UMASK
{ {
"os/umask", os_umask, "os/umask", os_umask,
JDOC("(os/umask mask)\n\n" JDOC("(os/umask mask)\n\n"
"Set a new umask, returns the old umask.") "Set a new umask, returns the old umask.")
}, },
#endif
{ {
"os/mkdir", os_mkdir, "os/mkdir", os_mkdir,
JDOC("(os/mkdir path)\n\n" JDOC("(os/mkdir path)\n\n"
@ -1369,6 +1375,7 @@ static const JanetReg os_cfuns[] = {
"Iff symlink is falsey or not provided, " "Iff symlink is falsey or not provided, "
"creates a hard link. Does not work on Windows.") "creates a hard link. Does not work on Windows.")
}, },
#ifndef JANET_NO_SYMLINKS
{ {
"os/symlink", os_symlink, "os/symlink", os_symlink,
JDOC("(os/symlink oldpath newpath)\n\n" JDOC("(os/symlink oldpath newpath)\n\n"
@ -1379,6 +1386,7 @@ static const JanetReg os_cfuns[] = {
JDOC("(os/readlink path)\n\n" JDOC("(os/readlink path)\n\n"
"Read the contents of a symbolic link. Does not work on Windows.\n") "Read the contents of a symbolic link. Does not work on Windows.\n")
}, },
#endif
#ifndef JANET_NO_PROCESSES #ifndef JANET_NO_PROCESSES
{ {
"os/execute", os_execute, "os/execute", os_execute,

View File

@ -138,6 +138,11 @@ extern "C" {
#define JANET_NO_UTC_MKTIME #define JANET_NO_UTC_MKTIME
#endif #endif
/* Add some windows flags */
#ifdef JANET_WINDOWS
#define JANET_NO_REALPATH
#endif
/* Define how global janet state is declared */ /* Define how global janet state is declared */
#ifdef JANET_SINGLE_THREADED #ifdef JANET_SINGLE_THREADED
#define JANET_THREAD_LOCAL #define JANET_THREAD_LOCAL