2001-02-28 04:20:36 +01:00
|
|
|
// Wrapper of C-language FILE struct -*- C++ -*-
|
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
|
2001-02-28 04:20:36 +01:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 2, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING. If not, write to the Free
|
|
|
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
// USA.
|
|
|
|
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
|
|
// library without restriction. Specifically, if other files instantiate
|
|
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
|
|
// this file and link it with other files to produce an executable, this
|
|
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
|
|
// the GNU General Public License. This exception does not however
|
|
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
|
|
// the GNU General Public License.
|
|
|
|
|
|
|
|
//
|
|
|
|
// ISO C++ 14882: 27.8 File-based streams
|
|
|
|
//
|
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
/** @file basic_file.h
|
|
|
|
* This is an internal header file, included by other library headers.
|
|
|
|
* You should not attempt to use it directly.
|
|
|
|
*/
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
#ifndef _CPP_BASIC_FILE
|
|
|
|
#define _CPP_BASIC_FILE 1
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
#pragma GCC system_header
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
#include <bits/c++config.h>
|
|
|
|
#include <ios>
|
2001-06-13 01:09:09 +02:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
// Generic declaration.
|
2001-06-13 01:09:09 +02:00
|
|
|
template<typename _CharT>
|
2002-02-12 05:35:58 +01:00
|
|
|
class __basic_file;
|
2001-06-13 01:09:09 +02:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
// Specialization.
|
|
|
|
template<>
|
|
|
|
class __basic_file<char>
|
2001-06-13 01:09:09 +02:00
|
|
|
{
|
2002-02-12 05:35:58 +01:00
|
|
|
// Underlying data source/sink.
|
2002-04-16 02:45:36 +02:00
|
|
|
__c_file* _M_cfile;
|
2002-02-12 05:35:58 +01:00
|
|
|
// True iff we opened _M_cfile, and thus must close it ourselves.
|
|
|
|
bool _M_cfile_created;
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
public:
|
|
|
|
__basic_file(__c_lock* __lock = 0);
|
|
|
|
|
|
|
|
void
|
|
|
|
_M_open_mode(ios_base::openmode __mode, int& __p_mode, int& __rw_mode,
|
|
|
|
char* __c_mode);
|
|
|
|
|
|
|
|
__basic_file*
|
|
|
|
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
__basic_file*
|
2002-04-30 21:04:43 +02:00
|
|
|
sys_open(__c_file* __file, ios_base::openmode);
|
|
|
|
|
|
|
|
__basic_file*
|
|
|
|
sys_open(int __fd, ios_base::openmode __mode, bool __del);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-04-29 09:00:50 +02:00
|
|
|
int
|
2002-02-12 05:35:58 +01:00
|
|
|
sys_getc();
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-04-29 09:00:50 +02:00
|
|
|
int
|
|
|
|
sys_ungetc(int);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
__basic_file*
|
|
|
|
close();
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
bool
|
2002-04-16 02:45:36 +02:00
|
|
|
is_open() const;
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
int
|
|
|
|
fd();
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
~__basic_file();
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
streamsize
|
re PR libstdc++/7744 (streambuf::in_avail() always returns 0 (zero) for cin input stream)
2003-03-09 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
PR libstdc++/7744
* config/io/basic_file_stdio.h (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): Add a boolean parameter __stdio.
* config/io/basic_file_stdio.cc (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): If __stdio == true, use fread (fwrite, fseek/ftell,
fseek/ftell, respectively), otherwise read (write, lseek, lseek,
respectively).
* include/bits/fstream.tcc (basic_filebuf<>::_M_convert_to_external,
_M_really_overflow, seekoff): Use the boolean parameter in the calls.
* include/std/std_fstream.h (sync): Likewise.
* src/fstream.cc (basic_filebuf<>::_M_underflow_common): Likewise.
* src/ios.cc (ios_base::Init::_S_ios_create(bool)): Revert libstdc++/8399
commit involving isatty(0).
* acinclude.m4 (GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1): Remove.
(GLIBCPP_CHECK_UNISTD_SUPPORT): Remove
* configure.in: Remove call.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* testsuite/27_io/narrow_stream_objects.cc (test11): Add.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r64051
2003-03-09 23:31:45 +01:00
|
|
|
xsputn(const char* __s, streamsize __n, bool __stdio);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
streamsize
|
re PR libstdc++/7744 (streambuf::in_avail() always returns 0 (zero) for cin input stream)
2003-03-09 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
PR libstdc++/7744
* config/io/basic_file_stdio.h (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): Add a boolean parameter __stdio.
* config/io/basic_file_stdio.cc (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): If __stdio == true, use fread (fwrite, fseek/ftell,
fseek/ftell, respectively), otherwise read (write, lseek, lseek,
respectively).
* include/bits/fstream.tcc (basic_filebuf<>::_M_convert_to_external,
_M_really_overflow, seekoff): Use the boolean parameter in the calls.
* include/std/std_fstream.h (sync): Likewise.
* src/fstream.cc (basic_filebuf<>::_M_underflow_common): Likewise.
* src/ios.cc (ios_base::Init::_S_ios_create(bool)): Revert libstdc++/8399
commit involving isatty(0).
* acinclude.m4 (GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1): Remove.
(GLIBCPP_CHECK_UNISTD_SUPPORT): Remove
* configure.in: Remove call.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* testsuite/27_io/narrow_stream_objects.cc (test11): Add.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r64051
2003-03-09 23:31:45 +01:00
|
|
|
xsgetn(char* __s, streamsize __n, bool __stdio);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
streamoff
|
re PR libstdc++/7744 (streambuf::in_avail() always returns 0 (zero) for cin input stream)
2003-03-09 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
PR libstdc++/7744
* config/io/basic_file_stdio.h (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): Add a boolean parameter __stdio.
* config/io/basic_file_stdio.cc (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): If __stdio == true, use fread (fwrite, fseek/ftell,
fseek/ftell, respectively), otherwise read (write, lseek, lseek,
respectively).
* include/bits/fstream.tcc (basic_filebuf<>::_M_convert_to_external,
_M_really_overflow, seekoff): Use the boolean parameter in the calls.
* include/std/std_fstream.h (sync): Likewise.
* src/fstream.cc (basic_filebuf<>::_M_underflow_common): Likewise.
* src/ios.cc (ios_base::Init::_S_ios_create(bool)): Revert libstdc++/8399
commit involving isatty(0).
* acinclude.m4 (GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1): Remove.
(GLIBCPP_CHECK_UNISTD_SUPPORT): Remove
* configure.in: Remove call.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* testsuite/27_io/narrow_stream_objects.cc (test11): Add.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r64051
2003-03-09 23:31:45 +01:00
|
|
|
seekoff(streamoff __off, ios_base::seekdir __way, bool __stdio,
|
2002-02-12 05:35:58 +01:00
|
|
|
ios_base::openmode __mode = ios_base::in | ios_base::out);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
streamoff
|
re PR libstdc++/7744 (streambuf::in_avail() always returns 0 (zero) for cin input stream)
2003-03-09 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
PR libstdc++/7744
* config/io/basic_file_stdio.h (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): Add a boolean parameter __stdio.
* config/io/basic_file_stdio.cc (__basic_file<>::xsgetn, xsputn,
seekoff, seekpos): If __stdio == true, use fread (fwrite, fseek/ftell,
fseek/ftell, respectively), otherwise read (write, lseek, lseek,
respectively).
* include/bits/fstream.tcc (basic_filebuf<>::_M_convert_to_external,
_M_really_overflow, seekoff): Use the boolean parameter in the calls.
* include/std/std_fstream.h (sync): Likewise.
* src/fstream.cc (basic_filebuf<>::_M_underflow_common): Likewise.
* src/ios.cc (ios_base::Init::_S_ios_create(bool)): Revert libstdc++/8399
commit involving isatty(0).
* acinclude.m4 (GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1): Remove.
(GLIBCPP_CHECK_UNISTD_SUPPORT): Remove
* configure.in: Remove call.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* testsuite/27_io/narrow_stream_objects.cc (test11): Add.
Co-Authored-By: Nathan Myers <ncm@cantrip.org>
From-SVN: r64051
2003-03-09 23:31:45 +01:00
|
|
|
seekpos(streamoff __pos, bool __stdio,
|
2002-02-12 05:35:58 +01:00
|
|
|
ios_base::openmode __mode = ios_base::in | ios_base::out);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
int
|
|
|
|
sync();
|
2003-03-28 19:28:47 +01:00
|
|
|
|
|
|
|
streamsize
|
|
|
|
showmanyc_helper(bool __stdio);
|
2002-02-12 05:35:58 +01:00
|
|
|
};
|
2001-02-28 04:20:36 +01:00
|
|
|
} // namespace std
|
2002-02-12 05:35:58 +01:00
|
|
|
|
|
|
|
#endif // _CPP_BASIC_FILE
|