User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:delete-file [2019/11/11 05:00]
cl:functions:delete-file [2019/11/15 20:00] (current)
Line 1: Line 1:
 +====== Function DELETE-FILE ======
 +
 +====Syntax====
 +  * **delete-file** //​filespec//​ → //​[[CL:​Constant Variables:​t]]//​
 +
 +====Arguments and Values====
 +  * //​filespec//​ - a //​[[CL:​Glossary:​pathname designator]]//​.
 +
 +====Description====
 +Deletes the //​[[CL:​Glossary:​file]]//​ specified by //​filespec//​.
 +
 +If the //​filespec//​ //​[[CL:​Glossary:​designator]]//​ is an open //​[[CL:​Glossary:​stream]]//,​ then //​filespec//​ and the file associated with it are affected (if the file system permits), in which case //​filespec//​ might be closed immediately,​ and the deletion might be immediate or delayed until //​filespec//​ is explicitly closed, depending on the requirements of the file system.
 +
 +It is //​[[CL:​Glossary:​implementation-dependent]]//​ whether an attempt to delete a nonexistent file is considered to be successful.
 +
 +**delete-file** returns //​[[CL:​Glossary:​true]]//​ if it succeeds, or signals an error of type **[[CL:​Types:​file-error]]** if it does not.
 +
 +The consequences are undefined if //​filespec//​ has a //​[[CL:​Glossary:​wild]]//​ component, or if //​filespec//​ has a **[[CL:​Constant Variables:​nil]]** component and the file system does not permit a **[[CL:​Constant Variables:​nil]]** component.
 +
 +====Examples====
 +<​blockquote>​
 +([[CL:​Macros:​with-open-file]] (s "​delete-me.text"​ :direction :​output ​
 +                                    :if-exists :error)) <​r>​[[CL:​Constant Variables:​nil|NIL]]</​r>​
 +([[CL:​Macros:​defparameter]] *p* ([[CL:​Functions:​probe-file]] "​delete-me.text"​)) <​r>​*P*</​r>​
 +*p* <​r>#​P"​R:>​fred>​delete-me.text.1"</​r>​
 +(delete-file *p*) <​r>​[[CL:​Constant Variables:​t|T]]</​r>​
 +([[CL:​Functions:​probe-file]] "​delete-me.text"​) <​r>//​[[CL:​Glossary:​false]]//</​r>​
 +([[CL:​Macros:​with-open-file]] (s "​delete-me.text"​ :direction :​output ​
 +                                    :if-exists :error)
 +  (delete-file s)) <​r>​[[CL:​Constant Variables:​t|T]]</​r>​
 +([[CL:​Functions:​probe-file]] "​delete-me.text"​) <​r>//​[[CL:​Glossary:​false]]//</​r>​
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +If the deletion operation is not successful, an error of type **[[CL:​Types:​file-error]]** is signaled.
 +
 +An error of type **[[CL:​Types:​file-error]]** might be signaled if //​filespec//​ is //​[[CL:​Glossary:​wild]]//​.
 +
 +====See Also====
 +**[[CL:​Types:​pathname|System Class PATHNAME]]**,​ **[[CL:​Types:​logical-pathname|System Classs LOGICAL-PATHNAME]]**,​{\secref\FileSystemConcepts},​
 +
 +{\secref\PathnamesAsFilenames}
 +
 +====Notes====
 +
 +None.
 +
 +
 +\issue{PATHNAME-LOGICAL:​ADD} \issue{PATHNAME-WILD:​NEW-FUNCTIONS} \issue{PATHNAME-LOGICAL:​ADD} \issue{FILE-OPEN-ERROR:​SIGNAL-FILE-ERROR}