open-binary-input-file, open-binary-output-file - open a binary file

LIBRARY

(import (scheme file))              ;R7RS

SYNOPSIS

(open-binary-input-file string)
(open-binary-output-file string)

DESCRIPTION

Takes a string for a filename and returns a binary input or output port respectively.

When opening a file for input it must already exist. If the file already exists when opening it for output the effect is unspecified.

RETURN VALUES

Both procedures return a single value; a fresh binary input or output port.

COMPATIBILITY

These procedures are unique to R7RS. The open-file-input-port(3scm) and open-file-output-port(3scm) procedures are compatible replacements with stricter specifications.

ERRORS

These procedure can raise exceptions satisfying the following predicates:
file-error? (R7RS)
Raised if the file cannot be opened. In particular, this is raised by open-binary-input-file if the file does not exist.
R7RS
It is an error if the wrong number of arguments was passed or an argument was outside its domain. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

SEE ALSO

open-file-input-port(3scm), file-error?(3scm)

STANDARDS

R7RS

HISTORY

These procedures first appeared in R7RS.

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.

BUGS

You should be aware of what your implementation does when the file already exists because there is no way to check for this condition before attempting to open a file. The text in R7RS explicitly says that the effect is unspecified when this happens.

You cannot check for this condition ahead of time using file-exists?(3scm) and delete-file(3scm) because they are prone to time-to-check to time-of-use (TTCTOU) bugs.

If this is a concern then open-file-output-port(3scm) can be used instead with appropriate options.


Markup created by unroff 1.0sc,    March 04, 2023.