From 251de734feb2be2d414255dff8358045116e28e1 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 31 Oct 2006 11:01:43 +0000 Subject: Expanded the scope of the stream system to include positional functions. Updated the Connection class so that it won't die horribly if you don't provide the pointers to updatable memory for the amount of time not spent waiting for data during a read. Also fiddled with the http test, as you can see...nothing important. --- src/sfile.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/sfile.cpp') diff --git a/src/sfile.cpp b/src/sfile.cpp index 9c5f830..3f5144d 100644 --- a/src/sfile.cpp +++ b/src/sfile.cpp @@ -22,16 +22,48 @@ void SFile::close() size_t SFile::read( char *pBuf, size_t nBytes ) { if( !fh ) - throw FileException("SFile not open."); + throw FileException("File not open."); return fread( pBuf, 1, nBytes, fh ); } -size_t SFile::write( char *pBuf, size_t nBytes ) +size_t SFile::write( const char *pBuf, size_t nBytes ) { if( !fh ) - throw FileException("SFile not open."); + throw FileException("File not open."); return fwrite( pBuf, 1, nBytes, fh ); } +long SFile::tell() +{ + if( !fh ) + throw FileException("File not open."); + + return ftell( fh ); +} + +void SFile::seek( long offset ) +{ + if( !fh ) + throw FileException("File not open."); + + fseek( fh, offset, SEEK_CUR ); +} + +void SFile::setPos( long pos ) +{ + if( !fh ) + throw FileException("File not open."); + + fseek( fh, pos, SEEK_SET ); +} + +void SFile::setPosEnd( long pos ) +{ + if( !fh ) + throw FileException("File not open."); + + fseek( fh, pos, SEEK_END ); +} + -- cgit v1.2.3