// $Id: CFileReader.cc,v 1.6 2003/04/23 09:20:58 ta_muto Exp $

#include <CFileReader.h>

wax::CFileReader::~CFileReader()
{
	if(fp != NULL) {
		close();
	}
}

bool wax::CFileReader::open()
{
	int count = 0;
	while((fp = fopen((const char*)path,"rb")) == NULL) {
		count++;
		if(count > 4)	return false;
		sleepTimer(1);
	}
	return true;
}

int wax::CFileReader::read(char* buffer, int size)
{
	if(fp == NULL)	return -1;
	return fread(buffer, sizeof(char), size, fp);
}

void wax::CFileReader::close()
{
	if(fp != NULL) {
		fclose(fp);
		fp = NULL;
	}
}
