#include <unistd.h>
#include <vector>

#ifndef BUFFEREDFILE_H
#define BUFFEREDFILE_H
struct charAndSize {
	char * data;
	int size;
	int alreadyRead;
} typedef charAndSize;

//Works like this..
//Other ways of working are somewhat confusing
//
//read 10a
//read 10b
//push 10a
//push 10b
//read 10a
//read 10b
//

class BufferedFile {
	public:
	BufferedFile(int fdesc);
	~BufferedFile();
	int Read(char * data, int size);
	int Write(const char * data, int size);
	int getFileHandle();
	void Close();
	void pushBack(char * data, int size);
	bool readReady();
	bool writeReady();
	void setWait(int w);
	int getWait();

	private:
	int timeToWait; //This is in microseconds
	bool ready(int rw);
	int fd;
	vector<charAndSize *> pushBackBlocks;
};
#endif

