1
0
Fork 0
cl-sites/novaspec.org/cl/f_delete-file.html
2025-02-05 18:52:26 +01:00

321 lines
No EOL
6.6 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>delete-file | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_delete-file.html"
><LINK REL="next" HREF="t_file-error.html" TYPE="text/html" TITLE="file-error"
><LINK REL="prev" HREF="f_rename-file.html" TYPE="text/html" TITLE="rename-file"
><LINK REL="up" HREF="20_2_Files_Dictionary.html" TYPE="text/html" TITLE="20.2 Files Dictionary"
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
><SCRIPT SRC="dpans.js%3F3909942064"
></SCRIPT
><SCRIPT SRC="apropos.js%3F3909942064"
></SCRIPT
></HEAD
><BODY
><DIV
><DIV CLASS="topnav"
><DIV CLASS="breadcrumb"
><SPAN CLASS="breadcrumb-item"
><A HREF="index.html"
>Common Lisp Nova Spec</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="20_Files.html"
>20. Files</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="20_2_Files_Dictionary.html"
>20.2 Files Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="f_delete-file.html"
>delete-file</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_rename-file.html" CLASS="prev"
>&#8592;</A
><SPAN ID="apropos-label"
>Apropos </SPAN
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
><A HREF="t_file-error.html" CLASS="next"
>&#8594;</A
></DIV
><DIV ID="apropos-res"
></DIV
></DIV
></DIV
><DIV CLASS="matter"
><DIV CLASS="com"
><DIV CLASS="begincom"
><HR
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="delete-file"
></SPAN
><B
>delete-file</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Function</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><P CLASS="j"
><B
>delete-file</B
> <SPAN CLASS="cmssi"
>filespec</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="misc"
><B
>t</B
></SPAN
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>filespec</VAR
> &#8212; a <A HREF="26_1_Glossary.html#pathname_designator"
><EM CLASS="term"
>pathname designator</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
>Deletes the <A HREF="26_1_Glossary.html#file"
><EM CLASS="term"
>file</EM
></A
> specified by <VAR CLASS="param"
>filespec</VAR
>. </P
><P CLASS="j"
>If the <VAR CLASS="param"
>filespec</VAR
> <A HREF="26_1_Glossary.html#designator"
><EM CLASS="term"
>designator</EM
></A
> is an open <A HREF="26_1_Glossary.html#stream"
><EM CLASS="term"
>stream</EM
></A
>, then <VAR CLASS="param"
>filespec</VAR
> and the file associated with it are affected (if the file system permits), in which case <VAR CLASS="param"
>filespec</VAR
> might be closed immediately, and the deletion might be immediate or delayed until <VAR CLASS="param"
>filespec</VAR
> is explicitly closed, depending on the requirements of the file system. </P
><P CLASS="j"
>It is <A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
> whether an attempt to delete a nonexistent file is considered to be successful. </P
><P CLASS="j"
><A HREF="f_delete-file.html" CLASS="funref"
><B
>delete-file</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> if it succeeds, or signals an error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_file-error.html" CLASS="typeref"
><B
>file-error</B
></A
> if it does not. </P
><P CLASS="j"
>The consequences are undefined if <VAR CLASS="param"
>filespec</VAR
> has a <A HREF="26_1_Glossary.html#wild"
><EM CLASS="term"
>wild</EM
></A
> component, or if <VAR CLASS="param"
>filespec</VAR
> has a <SPAN CLASS="misc"
><B
>nil</B
></SPAN
> component and the file system does not permit a <SPAN CLASS="misc"
><B
>nil</B
></SPAN
> component.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
> (with-open-file (s "delete-me.text" :direction :output :if-exists :error))
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> NIL
(setq p (probe-file "delete-me.text")) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> #P"R:&gt;fred&gt;delete-me.text.1"
(delete-file p) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> T
(probe-file "delete-me.text") <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>
(with-open-file (s "delete-me.text" :direction :output :if-exists :error)
(delete-file s))
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> T
(probe-file "delete-me.text") <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
></PRE
></DD
><DT
><B
>Exceptional Situations</B
></DT
><DD
><P CLASS="j"
>If the deletion operation is not successful, an error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_file-error.html" CLASS="typeref"
><B
>file-error</B
></A
> is signaled. </P
><P CLASS="j"
>An error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_file-error.html" CLASS="typeref"
><B
>file-error</B
></A
> might be signaled if <VAR CLASS="param"
>filespec</VAR
> is <A HREF="26_1_Glossary.html#wild"
><EM CLASS="term"
>wild</EM
></A
>.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="t_pathname.html" CLASS="typeref"
><B
>pathname</B
></A
>, <A HREF="t_logical-pathname.html" CLASS="typeref"
><B
>logical-pathname</B
></A
>, <A HREF="20_1_File_System_Concepts.html#sec_20_1" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>20.1</SPAN
> <SPAN CLASS="cmr"
>(File</SPAN
> <SPAN CLASS="cmr"
>System</SPAN
> <SPAN CLASS="cmr"
>Concepts)</SPAN
></A
>, <A HREF="19_1_Overview_of_Filenames.html#sec_19_1_2" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>19.1.2</SPAN
> <SPAN CLASS="cmr"
>(Pathnames</SPAN
> <SPAN CLASS="cmr"
>as</SPAN
> <SPAN CLASS="cmr"
>Filenames)</SPAN
></A
></P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_rename-file.html" CLASS="prev"
>&#8592;</A
><A HREF="t_file-error.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>