#include <RawFile.h>
Public Member Functions | |
int | close () |
Close file if necessary. | |
int | eof () |
Check end of file. | |
bool | fail () |
It is not OK. | |
FILE * | GetPointer () |
Get file pointer. | |
int | ignore (long offset) |
Ignore some bytes. | |
bool | isRFIO () |
Castor flag. | |
bool | ok () |
It is OK (i.e. file was correctly opened) | |
RawFile * | open (const char *path) |
Open file. | |
RawFile (const char *path) | |
Usual constructor. | |
RawFile () | |
Default constructor. | |
int | read (void *data, size_t nbytes) |
Read from file. | |
int | seek (long offset, int whence) |
Go somewhere. | |
long | tell () |
Tell instruction. | |
virtual | ~RawFile () |
Destructor. | |
Private Attributes | |
FILE * | inputFile |
bool | rfioFlag |
Utility class to open, read and manage local and rfio files in a transparent way
RawFile::RawFile | ( | ) |
RawFile::RawFile | ( | const char * | path | ) |
RawFile::~RawFile | ( | ) | [virtual] |
int RawFile::close | ( | void | ) |
Close file if necessary.
Definition at line 60 of file RawFile.cc.
References inputFile, rfio_fclose(), and rfioFlag.
Referenced by DTDDUFileReader::~DTDDUFileReader(), DTROS25FileReader::~DTROS25FileReader(), DTROS8FileReader::~DTROS8FileReader(), and ~RawFile().
int RawFile::eof | ( | ) |
Check end of file.
Definition at line 100 of file RawFile.cc.
References inputFile, rfio_feof(), and rfioFlag.
Referenced by DTROS25FileReader::checkEndOfFile(), DTROS8FileReader::checkEndOfFile(), and DTDDUFileReader::checkEndOfFile().
bool RawFile::fail | ( | ) |
It is not OK.
Definition at line 78 of file RawFile.cc.
References ok().
Referenced by DTDDUFileReader::DTDDUFileReader(), DTROS25FileReader::DTROS25FileReader(), and DTROS8FileReader::DTROS8FileReader().
{ return !ok();}
FILE * RawFile::GetPointer | ( | ) |
Get file pointer.
Definition at line 74 of file RawFile.cc.
References inputFile.
{ return inputFile;}
int RawFile::ignore | ( | long | offset | ) |
Ignore some bytes.
Definition at line 98 of file RawFile.cc.
References seek().
Referenced by DTDDUFileReader::DTDDUFileReader().
bool RawFile::isRFIO | ( | ) |
bool RawFile::ok | ( | ) |
It is OK (i.e. file was correctly opened)
Definition at line 76 of file RawFile.cc.
References inputFile.
Referenced by fail().
{ return (inputFile!=0);}
RawFile * RawFile::open | ( | const char * | path | ) |
Open file.
Definition at line 27 of file RawFile.cc.
References gather_cfg::cout, lut2db_cfg::filename, inputFile, prof2calltree::prefix, rfio_fopen(), and rfioFlag.
Referenced by DTDDUFileReader::DTDDUFileReader(), DTROS25FileReader::DTROS25FileReader(), DTROS8FileReader::DTROS8FileReader(), and RawFile().
{ //cout << " Full path: " << path << endl; char* chaux = new char[strlen(path)+1]; strcpy(chaux,path); char* prefix = strtok(chaux,":"); //cout << " Prefix: " << prefix << endl; char* filename = prefix; if (strlen(prefix)<strlen(path)) filename = strtok(0,":"); //cout << " Filename: " << filename << endl; if (strcmp(prefix,"rfio")==0) rfioFlag = true; if (strcmp(prefix,"castor")==0) rfioFlag = true; if (rfioFlag) { char chopt[] = "r"; inputFile = rfio_fopen(filename,chopt); } else { char chopt[] = "rb"; inputFile = fopen(filename,chopt); } if( !inputFile ) { cout << "RawFile: the input file '" << filename << "' is not present" << endl; } else { cout << "RawFile: DAQ file '" << filename << "' was succesfully opened" << endl; } return this; }
int RawFile::read | ( | void * | data, |
size_t | nbytes | ||
) |
Read from file.
Definition at line 82 of file RawFile.cc.
References inputFile, rfio_fread(), and rfioFlag.
Referenced by DTDDUFileReader::dmaUnpack(), DTDDUFileReader::DTDDUFileReader(), DTDDUFileReader::fillRawData(), DTROS25FileReader::fillRawData(), and DTROS8FileReader::fillRawData().
int RawFile::seek | ( | long | offset, |
int | whence | ||
) |
Go somewhere.
Definition at line 90 of file RawFile.cc.
References inputFile, rfio_fseek(), and rfioFlag.
Referenced by ignore().
long RawFile::tell | ( | ) |
Tell instruction.
Definition at line 108 of file RawFile.cc.
References inputFile, rfio_ftell(), and rfioFlag.
{ if (rfioFlag) { return rfio_ftell(inputFile); } else { return ftell(inputFile); } }
FILE* RawFile::inputFile [private] |