adding (scheme file) bindings

This commit is contained in:
Alex Shinn 2011-10-06 21:18:08 +09:00
parent 0bffb295b5
commit 828e2aaa68
3 changed files with 15 additions and 1 deletions

12
eval.c
View file

@ -1018,6 +1018,18 @@ sexp sexp_open_output_file_op (sexp ctx sexp_api_params(self, n), sexp path) {
return sexp_make_output_port(ctx, out, path);
}
sexp sexp_open_binary_input_file (sexp ctx sexp_api_params(self, n), sexp path) {
sexp res = sexp_open_input_file_op(ctx, self, n, path);
if (sexp_portp(res)) sexp_port_binaryp(res) = 1;
return res;
}
sexp sexp_open_binary_output_file (sexp ctx sexp_api_params(self, n), sexp path) {
sexp res = sexp_open_output_file_op(ctx, self, n, path);
if (sexp_portp(res)) sexp_port_binaryp(res) = 1;
return res;
}
sexp sexp_close_port_op (sexp ctx sexp_api_params(self, n), sexp port) {
sexp_assert_type(ctx, sexp_portp, SEXP_OPORT, port);
if (! sexp_port_openp(port))

View file

@ -1,6 +1,6 @@
(define-library (scheme file)
(import (scheme))
(import (scheme) (only (chibi filesystem) delete-file file-exists?))
(export
call-with-input-file call-with-output-file
delete-file file-exists?

View file

@ -143,6 +143,8 @@ _FN2(SEXP_NULL, SEXP_NULL, SEXP_NULL, "append2", 0, sexp_append2_op),
_FN1(_I(SEXP_VECTOR), SEXP_NULL, "list->vector", 0, sexp_list_to_vector_op),
_FN1(_I(SEXP_IPORT), _I(SEXP_STRING), "open-input-file", 0, sexp_open_input_file_op),
_FN1(_I(SEXP_OPORT), _I(SEXP_STRING), "open-output-file", 0, sexp_open_output_file_op),
_FN1(_I(SEXP_IPORT), _I(SEXP_STRING), "open-binary-input-file", 0, sexp_open_binary_input_file),
_FN1(_I(SEXP_OPORT), _I(SEXP_STRING), "open-binary-output-file", 0, sexp_open_binary_output_file),
_FN1(SEXP_VOID, _I(SEXP_IPORT), "close-input-port", 0, sexp_close_port_op),
_FN1(SEXP_VOID, _I(SEXP_OPORT), "close-output-port", 0, sexp_close_port_op),
_FN0(_I(SEXP_ENV), "make-environment", 0, sexp_make_env_op),