//*-- Author : J.Wuestenfeld
//*-- Modified : 11/19/2003 by J.Wuestenfeld

//_HADES_CLASS_DESCRIPTION 
//////////////////////////////////////////////////////
//HRfioFile
//
//  Class used for reading HLD events from file on taperobot
//  Instantiates real access depending on robot (adsm or tsm)
//
/////////////////////////////////////////////////////

using namespace std;

#include <string>
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "hrfiofile.h"
#include "hrfiofiletsm.h"

ClassImp(HRFIOFile)

   HRFIOFile::HRFIOFile(const char *name, int mode)
{
  // Default constructor, open file

  fname = new TString(name);
  fmode = mode;
  status = ios::badbit
  pos = 0;
  if(fname->BeginsWith("lxgstore:"))
    file = new HRFIOFileTSM(name,mode);
  file->open(name,mode);
}

 HRFIOFile::~HRFIOFile(void)
{
  // Default destructor
  if(close())
    cout << "Error closing file" << endl;
  if(fname)
    delete fname;
}

 int HRFIOFile::open(const char *name, int mode)
{
  // open file on taperobot with name and mode. Tests first if file is accessible.
  // Return 0 on success, -1 otherwise.
  if(file)
    return file->open(name,mode);
  else
    return -1;
}

 int HRFIOFile::close(void)
{
  // Closes file. Return 0 if closed, -1 if no file opened.
  if(file)
    return file->close();
  else
    return -1;
}

 int HRFIOFile::access(const char *name, int mode)
{
  // Tests for accessibility of file on taperobot.
  // Returns 0 on success, -1 in case of failure.
  // If mode is set to 0 returns 1.
  TString *tmp;

  tmp = new TString(name);
  if(tmp->BeginsWith("lxgstore:"))
    {
      delete tmp;
      return HRFIOFileTSM::access(name,mode);
    }
  else
    delete tmp;
  return -1;
}

 int HRFIOFile::read(char *buffer, int len)
{
  // Reads a buffer with length len from the file
  if(file)
    return file->read(buffer,len);
  else
    return -1;
}

 int HRFIOFile::write(const char *buffer, int len)
{
  // Writes buffer to file. NOT TESTED!!
  if(file)
    return file->write(buffer,len);
  else
    return -1;
}

 HRFIOFileTSM& HRFIOFile::seekp(streampos n)
{
  // Moves accesspointer in file relative to current position.
  return seekg(n,(ios::seekdir
}

 HRFIOFileTSM& HRFIOFile::seekg(streampos offs, int p)
{
  // Moves accesspointer in file relative to position p.
  // p can be one of : ios::beg
  return file->seekg(offs,p);
}

 streampos HRFIOFile::tellg(void)
{
  // Returns current position in file.
  if(file)
    return file->tellg();
  else
    return -1;
}

 void HRFIOFile::ignore(int max, int term)
{
  // Ignore max bytes in file. Moves access pointer to new position
  seekp(max);
}

 Bool_t HRFIOFile::good(void)
{
  // Returns kTRUE, if lase operation was successfull, kFALSE otherwise.
  if(file)
    return file->good();
  else return -1;
}

 Bool_t HRFIOFile::eof(void)
{
  // Returns kTRUE if accesspointer has reached the end of file marker, kFALSE otherwise.
  if(file)
    return file->eof();
  else
    return -1;
}

 Bool_t HRFIOFile::fail(void)
{
  // Returns kTRUE if last operation failed, kFALSE otherwise.
  // File unusable!
  return (status & ios::failbit
}

 Bool_t HRFIOFile::bad(void)
{
  // Returns kTRUE, if last operation failed, but error can be repaired. 
  if(file)
    return file->bad();
  else
    return -1;
}

 int HRFIOFile::rdstat(void)
{
  // Returns status.
  if(file)
    return file->rdstat();
  else
    return -1;
}

HRFIOFile& HRFIOFile::operator>>(HRFIOFile& u)
{
  // Operator to write to the file. NOT IMPLEMENTED!
  return *this;
}

HRFIOFile& HRFIOFile::operator<<( const HRFIOFile& u)
{
  // Operator to read from the file. NOT IMPLEMENTED!
  return *this;
}


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.