aboutsummaryrefslogtreecommitdiff
path: root/src/file.cpp
blob: 9910b8a941e1c0037bfc1b65a5aad8aded313699 (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 "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 );
}