#ifndef TOOLBOX_FILENO_H
#define TOOLBOX_FILENO_H

#include <sys/types.h>

class cTBFileNo {
private:
	int    m_Filed;

	size_t m_BytesRead;
	size_t m_BytesWritten;

	bool   m_IsEof;

public:
	cTBFileNo(void);
	virtual ~cTBFileNo();
	
	virtual ssize_t SysRead(void *Buffer, size_t Length) = 0;
	virtual ssize_t SysWrite(const void *Buffer, size_t Length) = 0;

	virtual bool Open(int Filed);
	virtual bool Close(void);

	virtual ssize_t Read(char *Buffer, size_t Size, size_t &Offset);
	virtual ssize_t Write(char *Buffer, size_t &Length);

	virtual bool IsOpen(void) const { return (m_Filed != -1); }
	virtual bool IsEof(void) const { return m_IsEof; }

	virtual int  FileNo(void) const { return m_Filed; }

	operator int () const { return m_Filed; }

	virtual size_t BytesRead(void) const { return m_BytesRead; }
	virtual size_t BytesWritten(void) const { return m_BytesWritten; }

  virtual void HasRead(size_t Bytes) { m_BytesRead += Bytes; }
  virtual void HasWritten(size_t Bytes) { m_BytesWritten += Bytes; }
};

#endif // TOOLBOX_FILENO_H
