// C++ code Copyright (C) David R. Evans G4AMJ/NQ0I

#include <defines.h>
#include <magtape.h>

#include <iostream.h>

// constructor
magtape::magtape(char* filename, int mode)
{ fd = open(filename, mode);
  if (fd == -1) then
  { cerr << "Error : unable to open file " << filename <<
            " in magtape::magtape(char*, int)\n";
    exit(-1);
  }
}

// destructor; explicitly rewinds the tape
magtape::~magtape(void)
{ rewind();
  close(fd);
}

// private -- execute an ioctl
void magtape::_execute(short int operation, daddr_t count)
{ struct mtop op;

  op.mt_op = operation;
  op.mt_count = count;
  ioctl(fd, MTIOCTOP, (char*)&op);
}
