mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 00:50:26 +00:00
Add janet_getjfile to C API.
This commit is contained in:
parent
8b9ad2dce8
commit
6273e56886
@ -2,6 +2,7 @@
|
|||||||
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 - ???
|
## Unreleased - ???
|
||||||
|
- Add `janet_getjfile` to C API.
|
||||||
- Add `:x` flag to os/execute to raise error when exit code is non-zero.
|
- Add `:x` flag to os/execute to raise error when exit code is non-zero.
|
||||||
- Don't run `main` when flychecking.
|
- Don't run `main` when flychecking.
|
||||||
- Add `:n` flag to `file/open` to raise an error if file cannot be opened.
|
- Add `:n` flag to `file/open` to raise an error if file cannot be opened.
|
||||||
|
@ -789,6 +789,10 @@ static const JanetReg io_cfuns[] = {
|
|||||||
|
|
||||||
/* C API */
|
/* C API */
|
||||||
|
|
||||||
|
JanetFile *janet_getjfile(const Janet *argv, int32_t n) {
|
||||||
|
return janet_getabstract(argv, n, &janet_file_type);
|
||||||
|
}
|
||||||
|
|
||||||
FILE *janet_getfile(const Janet *argv, int32_t n, int *flags) {
|
FILE *janet_getfile(const Janet *argv, int32_t n, int *flags) {
|
||||||
JanetFile *iof = janet_getabstract(argv, n, &janet_file_type);
|
JanetFile *iof = janet_getabstract(argv, n, &janet_file_type);
|
||||||
if (NULL != flags) *flags = iof->flags;
|
if (NULL != flags) *flags = iof->flags;
|
||||||
@ -813,17 +817,18 @@ FILE *janet_unwrapfile(Janet j, int *flags) {
|
|||||||
void janet_lib_io(JanetTable *env) {
|
void janet_lib_io(JanetTable *env) {
|
||||||
janet_core_cfuns(env, NULL, io_cfuns);
|
janet_core_cfuns(env, NULL, io_cfuns);
|
||||||
janet_register_abstract_type(&janet_file_type);
|
janet_register_abstract_type(&janet_file_type);
|
||||||
|
int default_flags = JANET_FILE_NOT_CLOSEABLE | JANET_FILE_SERIALIZABLE;
|
||||||
/* stdout */
|
/* stdout */
|
||||||
janet_core_def(env, "stdout",
|
janet_core_def(env, "stdout",
|
||||||
janet_makefile(stdout, JANET_FILE_APPEND | JANET_FILE_NOT_CLOSEABLE | JANET_FILE_SERIALIZABLE),
|
janet_makefile(stdout, JANET_FILE_APPEND | default_flags),
|
||||||
JDOC("The standard output file."));
|
JDOC("The standard output file."));
|
||||||
/* stderr */
|
/* stderr */
|
||||||
janet_core_def(env, "stderr",
|
janet_core_def(env, "stderr",
|
||||||
janet_makefile(stderr, JANET_FILE_APPEND | JANET_FILE_NOT_CLOSEABLE | JANET_FILE_SERIALIZABLE),
|
janet_makefile(stderr, JANET_FILE_APPEND | default_flags),
|
||||||
JDOC("The standard error file."));
|
JDOC("The standard error file."));
|
||||||
/* stdin */
|
/* stdin */
|
||||||
janet_core_def(env, "stdin",
|
janet_core_def(env, "stdin",
|
||||||
janet_makefile(stdin, JANET_FILE_READ | JANET_FILE_NOT_CLOSEABLE | JANET_FILE_SERIALIZABLE),
|
janet_makefile(stdin, JANET_FILE_READ | default_flags),
|
||||||
JDOC("The standard input file."));
|
JDOC("The standard input file."));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1545,6 +1545,7 @@ extern JANET_API const JanetAbstractType janet_file_type;
|
|||||||
JANET_API Janet janet_makefile(FILE *f, int32_t flags);
|
JANET_API Janet janet_makefile(FILE *f, int32_t flags);
|
||||||
JANET_API FILE *janet_getfile(const Janet *argv, int32_t n, int32_t *flags);
|
JANET_API FILE *janet_getfile(const Janet *argv, int32_t n, int32_t *flags);
|
||||||
JANET_API FILE *janet_dynfile(const char *name, FILE *def);
|
JANET_API FILE *janet_dynfile(const char *name, FILE *def);
|
||||||
|
JANET_API JanetFile *janet_getjfile(const Janet *argv, int32_t n);
|
||||||
JANET_API JanetAbstract janet_checkfile(Janet j);
|
JANET_API JanetAbstract janet_checkfile(Janet j);
|
||||||
JANET_API FILE *janet_unwrapfile(Janet j, int32_t *flags);
|
JANET_API FILE *janet_unwrapfile(Janet j, int32_t *flags);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user