delete-file - delete a file
(import (rnrs)) ;R6RS
(import (rnrs files)) ;R6RS
(import (scheme file)) ;R7RS
Deletes the named file if it exists and can be deleted.
Returns unspecified values.
Returns an unspecified value.
(display "Hello, temporary world!\n" p)))
This procedure is used to delete files. It is commonly used to remove
existing output files before writing new output files. In R6RS systems
this is handled without race conditions with (file-options no-fail),
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 that satisfy the following predicates.
- assertion-violation? (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.
- i/o-filename-error? (R6RS), file-error? (R7RS)
The file does not exist or cannot be deleted.
This procedure is new to R6RS and R7RS, but it existed previously in
early Scheme running on MacLISP as
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
If a program checks if a file exists using
then another program may still have deleted the file before the second
call. It is better to wrap
Another approach is to use (file-options no-fail), see
Markup created by unroff 1.0sc, March 04, 2023.