aboutsummaryrefslogtreecommitdiff
path: root/src/file.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-10-27 23:08:24 +0000
committerMike Buland <eichlan@xagasoft.com>2006-10-27 23:08:24 +0000
commitfa6e658f87726b4108e8019805a2b3387d6d8517 (patch)
tree17f1059a2a60f2223473435a51118110993fd578 /src/file.cpp
parente8f7e6ea10efede39afa1698779ed15889cc2fba (diff)
downloadlibbu++-fa6e658f87726b4108e8019805a2b3387d6d8517.tar.gz
libbu++-fa6e658f87726b4108e8019805a2b3387d6d8517.tar.bz2
libbu++-fa6e658f87726b4108e8019805a2b3387d6d8517.tar.xz
libbu++-fa6e658f87726b4108e8019805a2b3387d6d8517.zip
Added the beginings of the new stream system.
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp37
1 files changed, 37 insertions, 0 deletions
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 @@
1#include "file.h"
2#include "exceptions.h"
3
4File::File( const char *sName, const char *sFlags )
5{
6 fh = fopen( sName, sFlags );
7}
8
9File::~File()
10{
11}
12
13void File::close()
14{
15 if( fh )
16 {
17 fclose( fh );
18 fh = NULL;
19 }
20}
21
22size_t File::read( char *pBuf, size_t nBytes )
23{
24 if( !fh )
25 throw FileException("File not open.");
26
27 return fread( pBuf, 1, nBytes, fh );
28}
29
30size_t File::write( char *pBuf, size_t nBytes )
31{
32 if( !fh )
33 throw FileException("File not open.");
34
35 return fwrite( pBuf, 1, nBytes, fh );
36}
37