* decl.c (initialize_local_var): Handle static variables here.
[official-gcc.git] / libio / fstream.cc
blob8930e0b9271f97ac81abd6ec5bc7586ca247345f
1 /* This is part of libio/iostream, providing -*- C++ -*- input/output.
2 Copyright (C) 1993 Free Software Foundation
4 This file is part of the GNU IO Library. This library is free
5 software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this library; see the file COPYING. If not, write to the Free
17 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 As a special exception, if you link this library with files
20 compiled with a GNU compiler to produce an executable, this does not cause
21 the resulting executable to be covered by the GNU General Public License.
22 This exception does not however invalidate any other reasons why
23 the executable file might be covered by the GNU General Public License.
25 Written by Per Bothner (bothner@cygnus.com). */
27 #ifdef __GNUG__
28 #pragma implementation
29 #endif
30 #define _STREAM_COMPAT
31 extern "C" {
32 #include "libioP.h"
34 #include <fstream.h>
36 inline void
37 fstreambase::__fb_init()
39 #ifdef _IO_NEW_STREAMS
40 #if !_IO_UNIFIED_JUMPTABLES
41 /* Uses the _IO_file_jump jumptable, for eficiency. */
42 __my_fb._jumps = &_IO_file_jumps;
43 __my_fb._vtable() = builtinbuf_vtable;
44 #endif
45 init (&__my_fb);
46 #else
47 init(filebuf::__new());
48 _flags &= ~ios::dont_close;
49 #endif
52 fstreambase::fstreambase()
54 __fb_init ();
57 fstreambase::fstreambase(int fd)
59 __fb_init ();
60 _IO_file_attach(rdbuf(), fd);
63 fstreambase::fstreambase(const char *name, int mode, int prot)
65 __fb_init ();
66 if (!rdbuf()->open(name, mode, prot))
67 set(ios::badbit);
70 fstreambase::fstreambase(int fd, char *p, int l)
72 #ifdef _IO_NEW_STREAMS
73 __fb_init ();
74 #else
75 init(filebuf::__new());
76 #endif
77 _IO_file_attach(rdbuf(), fd);
78 _IO_file_setbuf(rdbuf(), p, l);
81 void fstreambase::open(const char *name, int mode, int prot)
83 clear();
84 if (!rdbuf()->open(name, mode, prot))
85 set(ios::badbit);
88 void fstreambase::close()
90 if (!rdbuf()->close())
91 set(ios::failbit);
94 void fstreambase::attach(int fd)
96 if (!rdbuf()->attach(fd))
97 set(ios::failbit);
100 #if 0
101 static int mode_to_sys(enum open_mode mode)
103 return O_WRONLY;
106 static char* fopen_cmd_arg(io_mode i)
108 return "w";
110 #endif