head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.40; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.57; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.03; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.00; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# sg_file.hxx

Go to the documentation of this file.

    00001
    00005 // Written by Curtis Olson, started November 1999.
    00006 //
    00007 // Copyright (C) 1999  Curtis L. Olson - curt@@flightgear.org
    00008 //
    00009 // This program is free software; you can redistribute it and/or
    00010 // modify it under the terms of the GNU General Public License as
    00011 // published by the Free Software Foundation; either version 2 of the
    00012 // License, or (at your option) any later version.
    00013 //
    00014 // This program is distributed in the hope that it will be useful, but
    00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
    00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00017 // General Public License for more details.
    00018 //
    00019 // You should have received a copy of the GNU General Public License
    00020 // along with this program; if not, write to the Free Software
    00021 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00022 //
    00023 // $Id: sg_file.hxx,v 1.6 2001/03/25 01:42:40 curt Exp $
    00024
    00025
    00026 #ifndef _SG_FILE_HXX
    00027 #define _SG_FILE_HXX
    00028
    00029
    00030 #ifndef __cplusplus
    00031 # error This library requires C++
    00032 #endif
    00033
    00034 #include <simgear/compiler.h>
    00035
    00036 #include <string>
    00037
    00038 #include <sys/types.h>          // for open(), read(), write(), close()
    00039 #include <sys/stat.h>           // for open(), read(), write(), close()
    00040 #include <fcntl.h>              // for open(), read(), write(), close()
    00041 #if !defined( _MSC_VER )
    00042 #  include <unistd.h>           // for open(), read(), write(), close()
    00043 #endif
    00044
    00045 #include "iochannel.hxx"
    00046
    00047 SG_USING_STD(string);
    00048
    00049
    00053 class SGFile : public SGIOChannel {
    00054
    00055     string file_name;
    00056     int fp;
    00057
    00058 public:
    00059
    00067     SGFile( const string& file );
    00068
    00070     ~SGFile();
    00071
    00072     // open the file based on specified direction
    00073     bool open( const SGProtocolDir dir );
    00074
    00075     // read a block of data of specified size
    00076     int read( char *buf, int length );
    00077
    00078     // read a line of data, length is max size of input buffer
    00079     int readline( char *buf, int length );
    00080
    00081     // write data to a file
    00082     int write( const char *buf, const int length );
    00083
    00084     // write null terminated string to a file
    00085     int writestring( const char *str );
    00086
    00087     // close file
    00088     bool close();
    00089
    00091     inline string get_file_name() const { return file_name; }
    00092 };
    00093
    00094
    00095 #endif // _SG_FILE_HXX
    00096
    00097

@ 1.3 log @Oops, try again. @ text @d91 1 a91 1