#ifndef __FORENSICS_FILEWRAPPER_HH__
#define __FORENSICS_FILEWRAPPER_HH__

#include "forensics.hh"
#include "error.hh"


class filewrapper
{
private:
  int fd;
  int64_t file_size;
  const unsigned char* memblock;

public:
  filewrapper (const std::string& name);

  int64_t size ();

  inline const unsigned char read (int64_t offset) const
  {
    if (offset < 0) {
      error ("seek offset out of bounds");
    }
    if (offset > file_size) {
      error ("seek offset out of bounds");
    }
    return memblock[offset];
  }

  inline void read (int64_t block, unsigned char* buffer) 
  {
    memcpy (buffer, &(memblock[block * BLOCK_SIZE]), BLOCK_SIZE);
  }
};

#endif
