summaryrefslogtreecommitdiff
path: root/src/sfile.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-10-31 11:01:43 +0000
committerMike Buland <eichlan@xagasoft.com>2006-10-31 11:01:43 +0000
commit251de734feb2be2d414255dff8358045116e28e1 (patch)
tree02a98b01c398c8c77ba7c73f15a034d72591530b /src/sfile.cpp
parentbdd4bdd8615b1587974312a92219cbeab0068a7a (diff)
downloadlibbu++-251de734feb2be2d414255dff8358045116e28e1.tar.gz
libbu++-251de734feb2be2d414255dff8358045116e28e1.tar.bz2
libbu++-251de734feb2be2d414255dff8358045116e28e1.tar.xz
libbu++-251de734feb2be2d414255dff8358045116e28e1.zip
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.
Diffstat (limited to '')
-rw-r--r--src/sfile.cpp38
1 files changed, 35 insertions, 3 deletions
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()
22size_t SFile::read( char *pBuf, size_t nBytes ) 22size_t SFile::read( char *pBuf, size_t nBytes )
23{ 23{
24 if( !fh ) 24 if( !fh )
25 throw FileException("SFile not open."); 25 throw FileException("File not open.");
26 26
27 return fread( pBuf, 1, nBytes, fh ); 27 return fread( pBuf, 1, nBytes, fh );
28} 28}
29 29
30size_t SFile::write( char *pBuf, size_t nBytes ) 30size_t SFile::write( const char *pBuf, size_t nBytes )
31{ 31{
32 if( !fh ) 32 if( !fh )
33 throw FileException("SFile not open."); 33 throw FileException("File not open.");
34 34
35 return fwrite( pBuf, 1, nBytes, fh ); 35 return fwrite( pBuf, 1, nBytes, fh );
36} 36}
37 37
38long SFile::tell()
39{
40 if( !fh )
41 throw FileException("File not open.");
42
43 return ftell( fh );
44}
45
46void SFile::seek( long offset )
47{
48 if( !fh )
49 throw FileException("File not open.");
50
51 fseek( fh, offset, SEEK_CUR );
52}
53
54void SFile::setPos( long pos )
55{
56 if( !fh )
57 throw FileException("File not open.");
58
59 fseek( fh, pos, SEEK_SET );
60}
61
62void SFile::setPosEnd( long pos )
63{
64 if( !fh )
65 throw FileException("File not open.");
66
67 fseek( fh, pos, SEEK_END );
68}
69