#ifndef BUFFER_FILE_HELPER_H_INCLUDED
#define BUFFER_FILE_HELPER_H_INCLUDED

#include "../stdafx.h"
#include "../common/common.h"
#include "utils/ibuffer_file_helper.h"

class FileHeper : IFileHeper
{
public:
	FileHeper();
	~FileHeper();

	bool CreateTempFile();
	bool writeChunk(void* pbData, size_t cbData, BOOL bResult);

	bool openFileReadonly(std::string fileUri);

	size_t getDataLength();
	std::vector<unsigned char> getDataChunk(size_t offset, size_t length);
	void releaseFile(bool clearUri = false);

	bool isFileOpened(bool forWriting = false);

	void setThrowOnError(bool valToSet);

protected:
	std::string m_fileUri;
	std::fstream m_fstream;
	bool m_deletOnClose;
	bool m_openedAsWritable;
	size_t m_cachedLength;
	bool m_bFailOnError;
};

#endif  //!BUFFER_FILE_HELPER_H_INCLUDED
