file-exists? - test if a file exists
(import (rnrs)) ;R6RS
(import (rnrs files)) ;R6RS
(import (scheme file)) ;R7RS
This procedure returns
if the named file exists at the time the procedure is called and
Returns a single boolean object.
;; Assuming a typical Unix-like system
This procedure is used to check if a file exists before trying to
perform some operation on it. One common usage is in a Scheme
implementation's library loader, which needs to check if a base
filename exists in one of multiple paths, often trying different file
Valid values for a file name include strings that name a file using
the native notation of filesystem paths on an implementation’s
underlying operating system, and may include implementation-dependent
values as well.
It is an error if filename is not a string. See the next section.
This procedure is absent from R5RS and earlier reports.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
This procedure is new in R6RS and its description was copied into
R7RS. It is absent from previous reports. Early Scheme running on
MacLISP could use the procedure
to check if a file exists.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Programs that check if a file exist and then immediately operate on it
are prone to race conditions. The file may have been removed
immediately after this procedure checked for its existence, or it
might have been created. This is often not a problem.
Markup created by unroff 1.0sc, March 04, 2023.