delete-file(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay bestie, welcome to delete-file(3scm) from the Scheme Programmer's Manual β€” the page for delete-file, which is literally just β€œdelete a file.” No notes, iconic behavior. πŸ’…

πŸ“š LIBRARY πŸ“š

Load it from whichever report you're living in, bestie:

(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. That's the whole vibe. Lowkey simple, highkey useful. πŸ¦‹

πŸŽ€ RETURN VALUES πŸŽ€

  • R6RS β€” returns unspecified values.
  • R7RS β€” returns an unspecified value.

πŸ¦‹ EXAMPLES πŸ¦‹

Here's the lil demo, bestie β€” it writes a temp file, then yeets it:

(call-with-output-file "temp.txt"
  (lambda (p)
    (display "Hello, temporary world!\n" p)))

(delete-file "temp.txt")

πŸ’… APPLICATION USAGE πŸ’…

So this procedure is used to delete files. It's 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). Slay. ✨

🌈 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.

Also: this procedure is absent from R5RS and earlier reports. Not invited, ig. πŸ™ˆ

🚨 ERRORS 🚨

This procedure can raise exceptions that satisfy the following predicates, bestie β€” so catch them if you're being careful:

  • 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. Look at her, a legacy icon. πŸ‘‘

πŸ’œ 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).

πŸ’– That's the whole delete-file(3scm) page, bestie β€” from the Scheme Programmer's Manual, footer date 2021-03-07. Periodt. πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from