mirror of
https://github.com/janet-lang/janet
synced 2024-11-04 15:56:17 +00:00
Merge pull request #230 from andrewchambers/file_api
Extend file api to allow creating and checking.
This commit is contained in:
commit
a2e515ab89
@ -663,6 +663,20 @@ FILE *janet_getfile(const Janet *argv, int32_t n, int *flags) {
|
|||||||
return iof->file;
|
return iof->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Janet janet_makefile(FILE *f, int flags) {
|
||||||
|
return makef(f, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
JanetAbstract janet_checkfile(Janet j) {
|
||||||
|
return janet_checkabstract(j, &cfun_io_filetype);
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* janet_unwrapfile(Janet j, int *flags) {
|
||||||
|
IOFile *iof = janet_unwrap_abstract(j);
|
||||||
|
if (NULL != flags) *flags = iof->flags;
|
||||||
|
return iof->file;
|
||||||
|
}
|
||||||
|
|
||||||
/* Module entry point */
|
/* Module entry point */
|
||||||
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);
|
||||||
|
@ -1464,8 +1464,11 @@ JANET_API void janet_setdyn(const char *name, Janet value);
|
|||||||
#define JANET_FILE_SERIALIZABLE 128
|
#define JANET_FILE_SERIALIZABLE 128
|
||||||
#define JANET_FILE_PIPED 256
|
#define JANET_FILE_PIPED 256
|
||||||
|
|
||||||
|
JANET_API Janet janet_makefile(FILE *f, int flags);
|
||||||
JANET_API FILE *janet_getfile(const Janet *argv, int32_t n, int *flags);
|
JANET_API FILE *janet_getfile(const Janet *argv, int32_t n, int *flags);
|
||||||
JANET_API FILE *janet_dynfile(const char *name, FILE *def);
|
JANET_API FILE *janet_dynfile(const char *name, FILE *def);
|
||||||
|
JANET_API JanetAbstract janet_checkfile(Janet j);
|
||||||
|
JANET_API FILE *janet_unwrapfile(Janet j, int *flags);
|
||||||
|
|
||||||
/* Marshal API */
|
/* Marshal API */
|
||||||
JANET_API void janet_marshal_size(JanetMarshalContext *ctx, size_t value);
|
JANET_API void janet_marshal_size(JanetMarshalContext *ctx, size_t value);
|
||||||
|
Loading…
Reference in New Issue
Block a user