Scheme Programmer's Manual

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

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(7scheme).

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?(3scheme), file-options(7scheme)

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

BUGS

If a program checks if a file exists using file-exists?(3) 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(7scheme). Another approach is to use (file-options no-fail), see file-options(7scheme).

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
RETURN VALUES
EXAMPLES
APPLICATION USAGE
COMPATIBILITY
ERRORS
SEE ALSO
STANDARDS
HISTORY
AUTHORS
BUGS
Return to Main Contents