2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
8 #include <proto/exec.h>
10 #include <aros/libcall.h>
16 #include "__stdcio_intbase.h"
19 #include <aros/debug.h>
21 /*****************************************************************************
35 stream - Stream to close.
38 Upon successful completion 0 is returned. Otherwise, EOF is
39 returned and the global variable errno is set to indicate the
40 error. In either case no further access to the stream is possible.
53 ******************************************************************************/
55 struct StdCIOIntBase
*StdCIOBase
=
56 (struct StdCIOIntBase
*)__aros_getbase_StdCIOBase();
59 char s
[L_tmpnam
+20] = "";
61 if (stream
->flags
& __STDCIO_STDIO_TMP
)
63 if (!NameFromFH(stream
->fh
, s
, L_tmpnam
+20))
65 /* Just leave the file in T: */
66 D(bug("[fclose]: Could not get name from fh, IoErr()=%d\n", IoErr()));
71 if (!(stream
->flags
& __STDCIO_STDIO_DONTCLOSE
))
73 if (Close(stream
->fh
))
78 errno
= __stdc_ioerr2errno(IoErr());
82 Remove((struct Node
*)stream
);
83 if (!(stream
->flags
& __STDCIO_STDIO_DONTFREE
))
84 FreePooled(StdCIOBase
->streampool
, stream
, sizeof(FILE));
88 D(bug("[fclose]: Deleting file '%s'\n", s
));
89 DeleteFile(s
); /* File will be left there if delete fails */