From bdd4bdd8615b1587974312a92219cbeab0068a7a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 31 Oct 2006 05:44:33 +0000 Subject: Changed the file class to be SFile so that it will collide less, all of them will be named like that, make life easier. --- src/sfile.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/sfile.cpp (limited to 'src/sfile.cpp') diff --git a/src/sfile.cpp b/src/sfile.cpp new file mode 100644 index 0000000..9c5f830 --- /dev/null +++ b/src/sfile.cpp @@ -0,0 +1,37 @@ +#include "sfile.h" +#include "exceptions.h" + +SFile::SFile( const char *sName, const char *sFlags ) +{ + fh = fopen( sName, sFlags ); +} + +SFile::~SFile() +{ +} + +void SFile::close() +{ + if( fh ) + { + fclose( fh ); + fh = NULL; + } +} + +size_t SFile::read( char *pBuf, size_t nBytes ) +{ + if( !fh ) + throw FileException("SFile not open."); + + return fread( pBuf, 1, nBytes, fh ); +} + +size_t SFile::write( char *pBuf, size_t nBytes ) +{ + if( !fh ) + throw FileException("SFile not open."); + + return fwrite( pBuf, 1, nBytes, fh ); +} + -- cgit v1.2.3