| delete-file(3scm) | Scheme Programmer's Manual | delete-file(3scm) |
NAME
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
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(3scm).
COMPATIBILITY
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. The filename can be retrieved with i/o-error-filename(3scm).
SEE ALSO
file-exists?(3scm), file-options(3scm)
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://weinholt.se/scheme/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(3scm). Another approach is to use (file-options no-fail), see file-options(3scm).
| 2021-03-07 |