delete-file - delete a file
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs files)) ;R6RS
(import (scheme file)) ;R7RS
SYNOPSIS
(delete-file filename)
DESCRIPTION
Deletes the named file if it exists and can be deleted.
RETURN VALUES
- R6RS
-
Returns unspecified values.
- R7RS
-
Returns an unspecified value.
EXAMPLES
(call-with-output-file "temp.txt"
(lambda (p)
(display "Hello, temporary world!\n" p)))
(delete-file "temp.txt")
APPLICATION USAGE
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),
see
file-options(7scm).
COMPATIBILITY
- R6RS
-
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.
- R7RS
-
It is an error if filename is not a string. See the next section.
This procedure is absent from R5RS and earlier reports.
ERRORS
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.
- R7RS
-
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.
SEE ALSO
file-exists?(3scm),
file-options(7scm)
STANDARDS
R6RS,
R7RS
HISTORY
This procedure is new to R6RS and R7RS, but it existed previously in
early Scheme running on MacLISP as
deletef.
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
If a program checks if a file exists using
file-exists?(3scm)
before calling
delete-file
then another program may still have deleted the file before the second
call. It is better to wrap
delete-file
in
guard(7scm).
Another approach is to use (file-options no-fail), see
file-options(7scm).
Markup created by unroff 1.0sc, March 04, 2023.