From fa6e658f87726b4108e8019805a2b3387d6d8517 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 27 Oct 2006 23:08:24 +0000 Subject: Added the beginings of the new stream system. --- src/file.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/file.cpp (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp new file mode 100644 index 0000000..9910b8a --- /dev/null +++ b/src/file.cpp @@ -0,0 +1,37 @@ +#include "file.h" +#include "exceptions.h" + +File::File( const char *sName, const char *sFlags ) +{ + fh = fopen( sName, sFlags ); +} + +File::~File() +{ +} + +void File::close() +{ + if( fh ) + { + fclose( fh ); + fh = NULL; + } +} + +size_t File::read( char *pBuf, size_t nBytes ) +{ + if( !fh ) + throw FileException("File not open."); + + return fread( pBuf, 1, nBytes, fh ); +} + +size_t File::write( char *pBuf, size_t nBytes ) +{ + if( !fh ) + throw FileException("File not open."); + + return fwrite( pBuf, 1, nBytes, fh ); +} + -- cgit v1.2.3