summaryrefslogtreecommitdiff
path: root/src/sfile.cpp
blob: 9c5f830205a76b05fcabd1effe1b6632382f9d8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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 );
}