45 lines
891 B
C
Raw Permalink Normal View History

2001-01-01 00:00:00 +01:00
#ifdef DESCRIPTION
*************************** DESCRIPTION ***********************************
This is a header-only class for reading a binary file. About the only
advantage over calling the functions directly is that this will
automatically close the file when the class goes out of scope.
read
seek
// *************************************************************************
#endif // DESCRIPTION
#ifndef __CREAD_H__
#define __CREAD_H__
class CRead
{
public:
CRead(PCSTR pszFileName) {
hf = _lopen(pszFileName, OF_READ | OF_SHARE_DENY_WRITE);
};
CRead(HFILE hfFile) {
hf = hfFile;
};
~CRead(void) {
if (hf != HFILE_ERROR)
_lclose(hf);
};
int read(void* pv, int cb) {
return _lread(hf, pv, cb); };
int seek(int offset, int origin = 0) {
return _llseek(hf, offset, origin); };
HFILE hf; // for those whose must have the handle
};
#endif // __CREAD_H__