ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
fReadXRootD Class Reference

#include <fReadXRootD.h>

Inheritance diagram for fReadXRootD:
Collaboration diagram for fReadXRootD:

Public Member Functions

 fReadXRootD ()
 
 ~fReadXRootD ()
 
bool isOpen ()
 
bool isEoF ()
 
bool fileExists (std::string fName) const
 
void openFile (std::string fName)
 
void closeFile ()
 
void readData (char *buffer, unsigned int sizeBytes)
 
int64_t getPosition ()
 
void setPosition (int64_t p)
 
void setPositionFromEnd (int64_t p)
 
fRead * newReader () const
 

Private Attributes

int m_pfd
 

Detailed Description

Definition at line 10 of file fReadXRootD.h.

Constructor & Destructor Documentation

◆ fReadXRootD()

fReadXRootD::fReadXRootD ( )

Definition at line 21 of file fReadXRootD.cxx.

22 {
23  m_pfd = 0;
24 }

◆ ~fReadXRootD()

fReadXRootD::~fReadXRootD ( )

Definition at line 26 of file fReadXRootD.cxx.

27 {
28  this->closeFile();
29 }

Member Function Documentation

◆ closeFile()

void fReadXRootD::closeFile ( )

Definition at line 58 of file fReadXRootD.cxx.

59 {
61  m_pfd = 0;
62 }

◆ fileExists()

bool fReadXRootD::fileExists ( std::string  fName) const

Definition at line 43 of file fReadXRootD.cxx.

44 {
45  int pfd = XrdPosixXrootd::Open(fName.c_str(), O_RDONLY);
46  if(pfd == 0) return false;
48  return true;
49 }

◆ getPosition()

int64_t fReadXRootD::getPosition ( )

Definition at line 88 of file fReadXRootD.cxx.

89 {
90  if(this->isOpen()) return XrdPosixXrootd::Lseek(m_pfd, 0, SEEK_CUR);
91  return -1;
92 }

◆ isEoF()

bool fReadXRootD::isEoF ( )

Definition at line 36 of file fReadXRootD.cxx.

37 {
38 //xrd eof??
39  return false;
40 }

◆ isOpen()

bool fReadXRootD::isOpen ( )

Definition at line 31 of file fReadXRootD.cxx.

32 {
33  return m_pfd != 0;
34 }

◆ newReader()

fRead * fReadXRootD::newReader ( ) const

Definition at line 104 of file fReadXRootD.cxx.

105 {
106  fReadXRootD * nfr = new fReadXRootD();
107  return (fRead *)nfr;
108 }

◆ openFile()

void fReadXRootD::openFile ( std::string  fName)

Definition at line 52 of file fReadXRootD.cxx.

53 {
54  if(this->isOpen()) this->closeFile();
55  m_pfd = XrdPosixXrootd::Open(fName.c_str(), O_RDONLY);
56 }

◆ readData()

void fReadXRootD::readData ( char *  buffer,
unsigned int  sizeBytes 
)

Definition at line 64 of file fReadXRootD.cxx.

65 {
66  if (sizeBytes==0) return;
67  if(this->isOpen())
68  {
69  unsigned int totalRead=0,ntry=0;
70  while(sizeBytes > totalRead)
71  {
72  int ret = XrdPosixXrootd::Read(m_pfd,buffer,sizeBytes);
73  totalRead += ret; ++ntry;
74  if(ntry>5) {
75  std::stringstream mystream;
76  mystream << "Problem reading from the data file. "
77  <<"fReadXRootD::readData asked to read "<<sizeBytes
78  <<" bytes and managed to read only "<<totalRead
79  <<" bytes.";
80  EventStorage::ReadingIssue ci(ERS_HERE, mystream.str().c_str());
81  ers::warning(ci);
82  return;
83  }
84  }
85  }
86 }

◆ setPosition()

void fReadXRootD::setPosition ( int64_t  p)

Definition at line 94 of file fReadXRootD.cxx.

95 {
96  if(this->isOpen()) XrdPosixXrootd::Lseek(m_pfd, (long long)p, SEEK_SET);
97 }

◆ setPositionFromEnd()

void fReadXRootD::setPositionFromEnd ( int64_t  p)

Definition at line 99 of file fReadXRootD.cxx.

100 {
101  if(this->isOpen()) XrdPosixXrootd::Lseek(m_pfd, (long long)p, SEEK_END);
102 }

Member Data Documentation

◆ m_pfd

int fReadXRootD::m_pfd
private

Definition at line 28 of file fReadXRootD.h.


The documentation for this class was generated from the following files:
XrdPosixXrootd::Lseek
static off_t Lseek(int fildes, off_t offset, int whence)
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
fReadXRootD::isOpen
bool isOpen()
Definition: fReadXRootD.cxx:31
rootconvert.fName
string fName
Definition: rootconvert.py:5
XrdPosixXrootd::Read
static size_t Read(int fildes, void *buf, size_t nbyte)
XrdPosixXrootd::Open
static int Open(const char *path, int oflag, mode_t mode=0, XrdPosixCallBack *cbP=0)
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
ret
T ret(T t)
Definition: rootspy.cxx:260
fReadXRootD
Definition: fReadXRootD.h:11
fReadXRootD::closeFile
void closeFile()
Definition: fReadXRootD.cxx:58
XrdPosixXrootd::Close
static int Close(int fildes)
fReadXRootD::m_pfd
int m_pfd
Definition: fReadXRootD.h:28
fReadXRootD::fReadXRootD
fReadXRootD()
Definition: fReadXRootD.cxx:21