/* * This program 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 of the License, or * (at your option) any later version. * * This program 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 Library General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Class: cFile // Created by: Kristian Mueller// Created on: Sat Jun 18 15:40:21 2005 // Inspired and copyed from // Lars Hildebrandt (Copyright (C) 2001) #ifndef _CFILE_H_ #define _CFILE_H_ #include <fcntl.h> #include <string> #include "cData.h" class cFile{ public: cFile(); virtual ~cFile(); // will open the file selected by sFileName bool openFile(const std::string sFileName, const int iMode = O_RDONLY); // will create and open the file sesected by sFileName bool createFile(const std::string sFileName, const int iMode = 0644); // checks if a file is open bool isOpen(void) const{ return iDescriptor != 0; }; // closes the filedescriptor void closeFile (void); // will write a char array to the file opened before const unsigned long writeToFile(cData &aInData) const; // writes a single char to the file const unsigned long writeToFile(const char iCharacter) const; // reads data from file // buffer has to be at least 1 byte longer then bytes const int readFromFile(char* sBuffer, const unsigned long iLength); // read a single byte from the file const unsigned long readFromFile(char& iCharacter); // read in c++ - style (iNumber bytes) const std::string readString(const int iLength = 1); // will return the name of the opened file const std::string getFileName(){return sFileName; }; // returnes the etate od the EOF bit bool isEof(){return bEof; }; protected: std::string sFileName; bool bEof; int iDescriptor; }; #endif //_CFILE_H_