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-16 02:45:36 +02:00
|
|
|
sys_open(__c_file* __file, ios_base::openmode __mode);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
char
|
|
|
|
sys_getc();
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
char
|
|
|
|
sys_ungetc(char);
|
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
|
|
|
|
xsputn(const char* __s, streamsize __n);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
streamsize
|
|
|
|
xsgetn(char* __s, streamsize __n);
|
2001-02-28 04:20:36 +01:00
|
|
|
|
2002-02-12 05:35:58 +01:00
|
|
|
streamoff
|
|
|
|
seekoff(streamoff __off, ios_base::seekdir __way,
|
|
|
|
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
|
|
|
|
seekpos(streamoff __pos,
|
|
|
|
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();
|
|
|
|
};
|
2001-02-28 04:20:36 +01:00
|
|
|
} // namespace std
|
2002-02-12 05:35:58 +01:00
|
|
|
|
|
|
|
#endif // _CPP_BASIC_FILE
|