1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/f_close.htm
2024-04-01 10:24:07 +02:00

65 lines
7.9 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Function CLOSE</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="m_w_open.htm">
<LINK REL=UP HREF="c_stream.htm">
<LINK REL=NEXT HREF="m_w_op_1.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="m_w_open.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_stream.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="m_w_op_1.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="close"><I>Function</I> <B>CLOSE</B></A> <P>
<P><B>Syntax:</B><P>
<P>
<B>close</B> <I>stream <TT>&amp;key</TT> abort</I> =&gt; <I>result</I><P>
<P>
<P><B>Arguments and Values:</B><P>
<P>
<I>stream</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> (either <A REL=DEFINITION HREF="26_glo_o.htm#open"><I>open</I></A> or <A REL=DEFINITION HREF="26_glo_c.htm#closed"><I>closed</I></A>). <P>
<I>abort</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. The default is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
<I>result</I>---<A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A> if the <I>stream</I> was <A REL=DEFINITION HREF="26_glo_o.htm#open"><I>open</I></A> at the time it was received as an <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A>, or <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A> otherwise. <P>
<P><B>Description:</B><P>
<P>
<A REL=DEFINITION HREF="#close"><B>close</B></A> closes <I>stream</I>. Closing a <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> means that it may no longer be used in input or output operations. The act of <I>closing</I> a <A REL=DEFINITION HREF="26_glo_f.htm#file_stream"><I>file stream</I></A> ends the association between the <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> and its associated <A REL=DEFINITION HREF="26_glo_f.htm#file"><I>file</I></A>; the transaction with the <A REL=DEFINITION HREF="26_glo_f.htm#file_system"><I>file system</I></A> is terminated, and input/output may no longer be performed on the <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>. <P>
If <I>abort</I> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, an attempt is made to clean up any side effects of having created <I>stream</I>. If <I>stream</I> performs output to a file that was created when the <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> was created, the file is deleted and any previously existing file is not superseded. <P>
It is permissible to close an already closed <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>, but in that case the <I>result</I> is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A>. <P>
After <I>stream</I> is closed, it is still possible to perform the following query operations upon it: <A REL=DEFINITION HREF="f_stmp.htm#streamp"><B>streamp</B></A>, <A REL=DEFINITION HREF="f_pn.htm#pathname"><B>pathname</B></A>, <A REL=DEFINITION HREF="f_tn.htm#truename"><B>truename</B></A>, <A REL=DEFINITION HREF="f_merge_.htm#merge-pathnames"><B>merge-pathnames</B></A>, <A REL=DEFINITION HREF="f_pn_hos.htm#pathname-host"><B>pathname-host</B></A>, <A REL=DEFINITION HREF="f_pn_hos.htm#pathname-device"><B>pathname-device</B></A>, <A REL=DEFINITION HREF="f_pn_hos.htm#pathname-directory"><B>pathname-directory</B></A>,<A REL=DEFINITION HREF="f_pn_hos.htm#pathname-name"><B>pathname-name</B></A>, <A REL=DEFINITION HREF="f_pn_hos.htm#pathname-type"><B>pathname-type</B></A>, <A REL=DEFINITION HREF="f_pn_hos.htm#pathname-version"><B>pathname-version</B></A>, <A REL=DEFINITION HREF="f_namest.htm#namestring"><B>namestring</B></A>, <A REL=DEFINITION HREF="f_namest.htm#file-namestring"><B>file-namestring</B></A>, <A REL=DEFINITION HREF="f_namest.htm#directory-namestring"><B>directory-namestring</B></A>, <A REL=DEFINITION HREF="f_namest.htm#host-namestring"><B>host-namestring</B></A>, <A REL=DEFINITION HREF="f_namest.htm#enough-namestring"><B>enough-namestring</B></A>, <A REL=DEFINITION HREF="f_open.htm#open"><B>open</B></A>, <A REL=DEFINITION HREF="f_probe_.htm#probe-file"><B>probe-file</B></A>, and <A REL=DEFINITION HREF="f_dir.htm#directory"><B>directory</B></A>. <P>
The effect of <A REL=DEFINITION HREF="#close"><B>close</B></A> on a <A REL=DEFINITION HREF="26_glo_c.htm#constructed_stream"><I>constructed stream</I></A> is to close the argument <I>stream</I> only. There is no effect on the <A REL=DEFINITION HREF="26_glo_c.htm#constituent"><I>constituents</I></A> of <A REL=DEFINITION HREF="26_glo_c.htm#composite_stream"><I>composite streams</I></A>. <P>
For a <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> created with <A REL=DEFINITION HREF="f_mk_s_2.htm#make-string-output-stream"><B>make-string-output-stream</B></A>, the result of <A REL=DEFINITION HREF="f_get_ou.htm#get-output-stream-string"><B>get-output-stream-string</B></A> is unspecified after <A REL=DEFINITION HREF="#close"><B>close</B></A>. <P>
<P><B>Examples:</B><P>
<P>
<PRE>
(setq s (make-broadcast-stream)) =&gt; #&lt;BROADCAST-STREAM&gt;
(close s) =&gt; T
(output-stream-p s) =&gt; <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
</PRE>
</TT> <P>
<P><B>Side Effects:</B><P>
<P>
The <I>stream</I> is <A REL=DEFINITION HREF="26_glo_c.htm#closed"><I>closed</I></A> (if necessary). If <I>abort</I> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> and the <I>stream</I> is an <A REL=DEFINITION HREF="26_glo_o.htm#output"><I>output</I></A> <A REL=DEFINITION HREF="26_glo_f.htm#file_stream"><I>file stream</I></A>, its associated <A REL=DEFINITION HREF="26_glo_f.htm#file"><I>file</I></A> might be deleted. <P>
<P><B>Affected By:</B> None.
<P>
<P><B>Exceptional Situations:</B> None.
<P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="f_open.htm#open"><B>open</B></A> <P>
<P><B>Notes:</B> None.
<P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss052.htm">CLOSE-CONSTRUCTED-STREAM:ARGUMENT-STREAM-ONLY</A><LI> <A REL=CHILD HREF="../Issues/iss053.htm">CLOSED-STREAM-OPERATIONS:ALLOW-INQUIRY</A><LI> <A REL=CHILD HREF="../Issues/iss299.htm">RETURN-VALUES-UNSPECIFIED:SPECIFY</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>