CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
XrdFile Class Reference

#include <XrdFile.h>

Inheritance diagram for XrdFile:
Storage IOInput IOOutput

Public Member Functions

virtual void abort (void)
 
virtual void close (void)
 
virtual void create (const char *name, bool exclusive=false, int perms=0666)
 
virtual void create (const std::string &name, bool exclusive=false, int perms=0666)
 
virtual void open (const char *name, int flags=IOFlags::OpenRead, int perms=0666)
 
virtual void open (const std::string &name, int flags=IOFlags::OpenRead, int perms=0666)
 
virtual IOOffset position (IOOffset offset, Relative whence=SET)
 
virtual bool prefetch (const IOPosBuffer *what, IOSize n)
 
virtual IOSize read (void *into, IOSize n)
 
virtual IOSize read (void *into, IOSize n, IOOffset pos)
 
virtual IOSize readv (IOBuffer *into, IOSize n)
 
virtual IOSize readv (IOPosBuffer *into, IOSize n)
 
virtual void resize (IOOffset size)
 
virtual IOSize write (const void *from, IOSize n)
 
virtual IOSize write (const void *from, IOSize n, IOOffset pos)
 
 XrdFile (void)
 
 XrdFile (IOFD fd)
 
 XrdFile (const char *name, int flags=IOFlags::OpenRead, int perms=0666)
 
 XrdFile (const std::string &name, int flags=IOFlags::OpenRead, int perms=0666)
 
 ~XrdFile (void)
 
- Public Member Functions inherited from Storage
virtual bool eof (void) const
 
virtual void flush (void)
 
virtual IOOffset position (void) const
 
IOSize read (IOBuffer into, IOOffset pos)
 
virtual void rewind (void)
 
virtual IOOffset size (void) const
 
 Storage (void)
 
IOSize write (IOBuffer from, IOOffset pos)
 
virtual IOSize writev (const IOPosBuffer *from, IOSize buffers)
 
virtual ~Storage (void)
 
- Public Member Functions inherited from IOInput
int read (void)
 
IOSize read (IOBuffer into)
 
IOSize xread (IOBuffer into)
 
IOSize xread (void *into, IOSize n)
 
IOSize xreadv (IOBuffer *into, IOSize buffers)
 
virtual ~IOInput (void)
 Destruct the stream. A no-op. More...
 
- Public Member Functions inherited from IOOutput
IOSize write (unsigned char byte)
 
IOSize write (IOBuffer from)
 
virtual IOSize writev (const IOBuffer *from, IOSize buffers)
 
IOSize xwrite (const void *from, IOSize n)
 
IOSize xwrite (IOBuffer from)
 
IOSize xwritev (const IOBuffer *from, IOSize buffers)
 
virtual ~IOOutput (void)
 Destruct the stream. A no-op. More...
 

Private Attributes

XrdClient * m_client
 
bool m_close
 
std::string m_name
 
IOOffset m_offset
 
XrdClientStatInfo m_stat
 

Additional Inherited Members

- Public Types inherited from Storage
enum  Relative { SET, CURRENT, END }
 

Detailed Description

Definition at line 9 of file XrdFile.h.

Constructor & Destructor Documentation

XrdFile::XrdFile ( void  )

Definition at line 6 of file XrdFile.cc.

7  : m_client (0),
8  m_offset (0),
9  m_close (false)
10 {}
bool m_close
Definition: XrdFile.h:54
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
XrdFile::XrdFile ( IOFD  fd)
XrdFile::XrdFile ( const char *  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)

Definition at line 12 of file XrdFile.cc.

References open().

15  : m_client (0),
16  m_offset (0),
17  m_close (false)
18 { open (name, flags, perms); }
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
bool m_close
Definition: XrdFile.h:54
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: XrdFile.cc:66
XrdFile::XrdFile ( const std::string &  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)

Definition at line 20 of file XrdFile.cc.

References flags, and open().

23  : m_client (0),
24  m_offset (0),
25  m_close (false)
26 { open (name.c_str (), flags, perms); }
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
bool m_close
Definition: XrdFile.h:54
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: XrdFile.cc:66
XrdFile::~XrdFile ( void  )

Definition at line 28 of file XrdFile.cc.

References m_close, and m_name.

29 {
30  if (m_close)
31  edm::LogError("XrdFileError")
32  << "Destructor called on XROOTD file '" << m_name
33  << "' but the file is still open";
34 }
bool m_close
Definition: XrdFile.h:54
std::string m_name
Definition: XrdFile.h:55

Member Function Documentation

void XrdFile::abort ( void  )
virtual

Definition at line 158 of file XrdFile.cc.

References m_client, m_close, m_offset, and m_stat.

Referenced by open().

159 {
160  delete m_client;
161  m_client = 0;
162  m_close = false;
163  m_offset = 0;
164  memset(&m_stat, 0, sizeof (m_stat));
165 }
XrdClientStatInfo m_stat
Definition: XrdFile.h:53
bool m_close
Definition: XrdFile.h:54
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
void XrdFile::close ( void  )
virtual

Reimplemented from Storage.

Definition at line 132 of file XrdFile.cc.

References m_client, m_close, m_name, m_offset, and m_stat.

Referenced by python.Vispa.Gui.BoxContentDialog.BoxContentDialog::keyPressEvent(), python.Vispa.Gui.FindDialog.FindDialog::keyPressEvent(), and open().

133 {
134  if (! m_client)
135  {
136  edm::LogError("XrdFileError")
137  << "XrdFile::close(name='" << m_name
138  << "') called but the file is not open";
139  m_close = false;
140  return;
141  }
142 
143  if (! m_client->Close())
144  edm::LogWarning("XrdFileWarning")
145  << "XrdFile::close(name='" << m_name
146  << "') failed with error '" << m_client->LastServerError()->errmsg
147  << "' (errno=" << m_client->LastServerError()->errnum << ")";
148  delete m_client;
149  m_client = 0;
150 
151  m_close = false;
152  m_offset = 0;
153  memset(&m_stat, 0, sizeof (m_stat));
154  edm::LogInfo("XrdFileInfo") << "Closed " << m_name;
155 }
XrdClientStatInfo m_stat
Definition: XrdFile.h:53
bool m_close
Definition: XrdFile.h:54
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
std::string m_name
Definition: XrdFile.h:55
void XrdFile::create ( const char *  name,
bool  exclusive = false,
int  perms = 0666 
)
virtual

Definition at line 38 of file XrdFile.cc.

References open(), IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenTruncate, and IOFlags::OpenWrite.

41 {
42  open (name,
44  | (exclusive ? IOFlags::OpenExclusive : 0)),
45  perms);
46 }
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: XrdFile.cc:66
void XrdFile::create ( const std::string &  name,
bool  exclusive = false,
int  perms = 0666 
)
virtual

Definition at line 49 of file XrdFile.cc.

References open(), IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenTruncate, and IOFlags::OpenWrite.

52 {
53  open (name.c_str (),
55  | (exclusive ? IOFlags::OpenExclusive : 0)),
56  perms);
57 }
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: XrdFile.cc:66
void XrdFile::open ( const char *  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)
virtual

Definition at line 66 of file XrdFile.cc.

References abort(), close(), edm::hlt::Exception, m_client, m_close, m_name, m_offset, m_stat, mergeVDriftHistosByStation::name, IOFlags::OpenAppend, IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenRead, IOFlags::OpenTruncate, and IOFlags::OpenWrite.

Referenced by create(), open(), and XrdFile().

69 {
70  m_name = name;
71 
72  // Actual open
73  if ((name == 0) || (*name == 0))
74  throw cms::Exception("XrdFile::open()")
75  << "Cannot open a file without a name";
76 
78  throw cms::Exception("XrdFile::open()")
79  << "Must open file '" << name << "' at least for read or write";
80 
81  // If I am already open, close old file first
82  if (m_client && m_close)
83  close();
84  else
85  abort();
86 
87  // Translate our flags to system flags
88  int openflags = 0;
89 
91  openflags |= kXR_open_updt;
92  else if (flags & IOFlags::OpenRead)
93  openflags |= kXR_open_read;
94 
96  throw cms::Exception("XrdFile::open()")
97  << "Opening file '" << name << "' in append mode not supported";
98 
100  {
101  if (! (flags & IOFlags::OpenExclusive))
102  openflags |= kXR_delete;
103  openflags |= kXR_new;
104  openflags |= kXR_mkpath;
105  }
106 
107  if ((flags & IOFlags::OpenTruncate) && (flags & IOFlags::OpenWrite))
108  openflags |= kXR_delete;
109 
110  m_client = new XrdClient(name);
111  if (! m_client->Open(perms, openflags)
112  || m_client->LastServerResp()->status != kXR_ok)
113  throw cms::Exception("XrdFile::open()")
114  << "XrdClient::Open(name='" << name
115  << "', flags=0x" << std::hex << openflags
116  << ", permissions=0" << std::oct << perms << std::dec
117  << ") => error '" << m_client->LastServerError()->errmsg
118  << "' (errno=" << m_client->LastServerError()->errnum << ")";
119 
120  if (! m_client->Stat(&m_stat))
121  throw cms::Exception("XrdFile::open()")
122  << "XrdClient::Stat(name='" << name
123  << ") => error '" << m_client->LastServerError()->errmsg
124  << "' (errno=" << m_client->LastServerError()->errnum << ")";
125 
126  m_offset = 0;
127  m_close = true;
128  edm::LogInfo("XrdFileInfo") << "Opened " << m_name;
129 }
virtual void close(void)
Definition: XrdFile.cc:132
XrdClientStatInfo m_stat
Definition: XrdFile.h:53
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
bool m_close
Definition: XrdFile.h:54
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
std::string m_name
Definition: XrdFile.h:55
virtual void abort(void)
Definition: XrdFile.cc:158
void XrdFile::open ( const std::string &  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)
virtual

Definition at line 60 of file XrdFile.cc.

References flags, and open().

63 { open (name.c_str (), flags, perms); }
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: XrdFile.cc:66
IOOffset XrdFile::position ( IOOffset  offset,
Relative  whence = SET 
)
virtual

Implements Storage.

Definition at line 360 of file XrdFile.cc.

References Storage::CURRENT, Storage::END, edm::hlt::Exception, m_client, m_offset, m_stat, evf::evtn::offset(), and Storage::SET.

361 {
362  if (! m_client)
363  throw cms::Exception("XrdFile::position()")
364  << "XrdFile::position() called on a closed file";
365 
366  switch (whence)
367  {
368  case SET:
369  m_offset = offset;
370  break;
371 
372  case CURRENT:
373  m_offset += offset;
374  break;
375 
376  case END:
377  m_offset = m_stat.size + offset;
378  break;
379 
380  default:
381  throw cms::Exception("XrdFile::position()")
382  << "XrdFile::position() called with incorrect 'whence' parameter";
383  }
384 
385  if (m_offset < 0)
386  m_offset = 0;
387  if (m_offset > m_stat.size)
388  m_stat.size = m_offset;
389 
390  return m_offset;
391 }
XrdClientStatInfo m_stat
Definition: XrdFile.h:53
IOOffset m_offset
Definition: XrdFile.h:52
unsigned int offset(bool)
XrdClient * m_client
Definition: XrdFile.h:51
bool XrdFile::prefetch ( const IOPosBuffer what,
IOSize  n 
)
virtual

Reimplemented from Storage.

Definition at line 348 of file XrdFile.cc.

References i, m_client, IOPosBuffer::offset(), csvReporter::r, and IOPosBuffer::size().

349 {
350  XReqErrorType r = kOK;
351  for (IOSize i = 0; i < n && r == kOK; ++i)
352  r = m_client->Read_Async(what[i].offset(), what[i].size());
353  return r == kOK;
354 }
int i
Definition: DBlmapReader.cc:9
XrdClient * m_client
Definition: XrdFile.h:51
IOOffset offset(void) const
Definition: IOPosBuffer.h:50
IOSize size(void) const
Definition: IOPosBuffer.h:60
size_t IOSize
Definition: IOTypes.h:14
IOSize XrdFile::read ( void *  into,
IOSize  n 
)
virtual

Read into into at most n number of bytes.

If this is a blocking stream, the call will block until some data can be read, end of input is reached, or an exception is thrown. For a non-blocking stream the available input is returned. If none is available, an exception is thrown.

Returns
The number of bytes actually read. This is less or equal to the size of the buffer. Zero indicates that the end of the input has been reached: end of file, or remote end closing for a connected channel like a pipe or a socket. Otherwise the value can be less than requested if limited amount of input is currently available for platform or implementation reasons.
Exceptions
Incase of error, a #IOError exception is thrown. This includes the situation where the input stream is in non-blocking mode and no input is currently available (FIXME: make this simpler; clarify which exception).

Implements IOInput.

Definition at line 169 of file XrdFile.cc.

References edm::hlt::Exception, m_client, m_name, m_offset, and asciidump::s.

170 {
171  if (n > 0x7fffffff)
172  throw cms::Exception("XrdFile::read()")
173  << "XrdFile::read(name='" << m_name << "', n=" << n
174  << ") too many bytes, limit is 0x7fffffff";
175 
176  int s = m_client->Read(into, m_offset, n);
177  if (s < 0)
178  throw cms::Exception("XrdFile::read()")
179  << "XrdClient::Read(name='" << m_name
180  << "', offset=" << m_offset << ", n=" << n
181  << ") failed with error '" << m_client->LastServerError()->errmsg
182  << "' (errno=" << m_client->LastServerError()->errnum << ")";
183  m_offset += s;
184  return s;
185 }
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
std::string m_name
Definition: XrdFile.h:55
string s
Definition: asciidump.py:422
IOSize XrdFile::read ( void *  into,
IOSize  n,
IOOffset  pos 
)
virtual

Reimplemented from Storage.

Definition at line 188 of file XrdFile.cc.

References edm::hlt::Exception, m_client, m_name, m_offset, and asciidump::s.

189 {
190  if (n > 0x7fffffff)
191  throw cms::Exception("XrdFile::read()")
192  << "XrdFile::read(name='" << m_name << "', n=" << n
193  << ") exceeds read size limit 0x7fffffff";
194 
195  int s = m_client->Read(into, pos, n);
196  if (s < 0)
197  throw cms::Exception("XrdFile::read()")
198  << "XrdClient::Read(name='" << m_name
199  << "', offset=" << m_offset << ", n=" << n
200  << ") failed with error '" << m_client->LastServerError()->errmsg
201  << "' (errno=" << m_client->LastServerError()->errnum << ")";
202  return s;
203 }
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
std::string m_name
Definition: XrdFile.h:55
string s
Definition: asciidump.py:422
IOSize XrdFile::readv ( IOBuffer into,
IOSize  buffers 
)
virtual

Read from the input stream into multiple scattered buffers. There are buffers to fill in an array starting at into; the memory those buffers occupy does not need to be contiguous. The buffers are filled in the order given, eac buffer is filled fully before the subsequent buffers.

If this is a blocking stream, the call will block until some data can be read, end of input is reached, or an exception is thrown. For a non-blocking stream the available input is returned. If none is available, an exception is thrown.

The base class implementation uses read(void *, IOSize) method, but derived classes may implement a more efficient alternative.

Returns
The number of bytes actually read. This is less or equal to the size of the buffer. Zero indicates that the end of the input has been reached: end of file, or remote end closing for a connected channel like a pipe or a socket. Otherwise the value can be less than requested if limited amount of input is currently available for platform or implementation reasons. Note that the return value indicates the number of bytes read, not the number of buffers; it is the sum total of bytes filled into all the buffers.
Exceptions
Incase of error, a #IOError exception is thrown. However if some data has already been read, the error is swallowed and the method returns the data read so far. It is assumed that persistent errors will occur anyway on the next read and sporadic errors like stream becoming unvailable can be ignored. Use xread() if a different policy is desirable.

Reimplemented from IOInput.

Definition at line 206 of file XrdFile.cc.

References runTheMatrix::data, edm::hlt::Exception, i, l1GtPatternGenerator_cfi::lengths, m_client, m_name, m_offset, n, pos, asciidump::s, IOBuffer::size(), and pileupDistInMC::total.

207 {
208  // Note that the XROOTD and our interfaces do not match.
209  // XROOTD expects readv() into a single monolithic buffer
210  // from multiple file locations, whereas we expect scatter
211  // gather buffers read from a single file location.
212  //
213  // We work around this mismatch for now by issuing a cache
214  // read on the background, and then individual reads.
216  std::vector<long long> offsets (n);
217  std::vector<int> lengths (n);
218  for (IOSize i = 0; i < n; ++i)
219  {
220  IOSize len = into[i].size();
221  if (len > 0x7fffffff)
222  throw cms::Exception("XrdFile::readv()")
223  << "XrdFile::readv(name='" << m_name << "')[" << i
224  << "].size=" << len << " exceeds read size limit 0x7fffffff";
225  offsets[i] = pos;
226  lengths[i] = len;
227  pos += len;
228  }
229 
230  // Prefetch into the cache (if any).
231  if (m_client->ReadV(0, &offsets[0], &lengths[0], n) < 0)
232  throw cms::Exception("XrdFile::readv()")
233  << "XrdClient::ReadV(name='" << m_name
234  << "') failed with error '" << m_client->LastServerError()->errmsg
235  << "' (errno=" << m_client->LastServerError()->errnum << ")";
236 
237  // Issue actual reads.
238  IOSize total = 0;
239  for (IOSize i = 0; i < n; ++i)
240  {
241  int s = m_client->Read(into[i].data(), offsets[i], lengths[i]);
242  if (s < 0)
243  {
244  if (i > 0)
245  break;
246  throw cms::Exception("XrdFile::readv()")
247  << "XrdClient::Read(name='" << m_name
248  << "', offset=" << offsets[i] << ", n=" << lengths[i]
249  << ") failed with error '" << m_client->LastServerError()->errmsg
250  << "' (errno=" << m_client->LastServerError()->errnum << ")";
251  }
252  total += s;
253  m_offset += s;
254  }
255 
256  return total;
257 }
int i
Definition: DBlmapReader.cc:9
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
IOSize size(void) const
Definition: IOBuffer.h:50
std::string m_name
Definition: XrdFile.h:55
int64_t IOOffset
Definition: IOTypes.h:19
size_t IOSize
Definition: IOTypes.h:14
string s
Definition: asciidump.py:422
IOSize XrdFile::readv ( IOPosBuffer into,
IOSize  n 
)
virtual

Reimplemented from Storage.

Definition at line 260 of file XrdFile.cc.

References runTheMatrix::data, edm::hlt::Exception, i, l1GtPatternGenerator_cfi::lengths, m_client, m_name, n, IOPosBuffer::offset(), asciidump::s, IOPosBuffer::size(), and pileupDistInMC::total.

261 {
262  // See comments in readv() above.
263  std::vector<long long> offsets (n);
264  std::vector<int> lengths (n);
265  for (IOSize i = 0; i < n; ++i)
266  {
267  IOSize len = into[i].size();
268  if (len > 0x7fffffff)
269  throw cms::Exception("XrdFile::readv()")
270  << "XrdFile::readv(name='" << m_name << "')[" << i
271  << "].size=" << len << " exceeds read size limit 0x7fffffff";
272  offsets[i] = into[i].offset();
273  lengths[i] = len;
274  }
275 
276  // Prefetch into the cache (if any).
277  if (m_client->ReadV(0, &offsets[0], &lengths[0], n) < 0)
278  throw cms::Exception("XrdFile::readv()")
279  << "XrdClient::ReadV(name='" << m_name
280  << "') failed with error '" << m_client->LastServerError()->errmsg
281  << "' (errno=" << m_client->LastServerError()->errnum << ")";
282 
283  // Issue actual reads.
284  IOSize total = 0;
285  for (IOSize i = 0; i < n; ++i)
286  {
287  int s = m_client->Read(into[i].data(), offsets[i], lengths[i]);
288  if (s < 0)
289  {
290  if (i > 0)
291  break;
292  throw cms::Exception("XrdFile::readv()")
293  << "XrdClient::Read(name='" << m_name
294  << "', offset=" << offsets[i] << ", n=" << lengths[i]
295  << ") failed with error '" << m_client->LastServerError()->errmsg
296  << "' (errno=" << m_client->LastServerError()->errnum << ")";
297  }
298  total += s;
299  }
300 
301  return total;
302 }
int i
Definition: DBlmapReader.cc:9
XrdClient * m_client
Definition: XrdFile.h:51
IOOffset offset(void) const
Definition: IOPosBuffer.h:50
std::string m_name
Definition: XrdFile.h:55
IOSize size(void) const
Definition: IOPosBuffer.h:60
size_t IOSize
Definition: IOTypes.h:14
string s
Definition: asciidump.py:422
void XrdFile::resize ( IOOffset  size)
virtual

Implements Storage.

Definition at line 394 of file XrdFile.cc.

References edm::hlt::Exception, and m_name.

Referenced by python.Vispa.Gui.TextDialog.TextDialog::__init__(), python.Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::__init__(), python.Vispa.Main.MainWindow.MainWindow::_loadIni(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

395 {
396  throw cms::Exception("XrdFile::resize()")
397  << "XrdFile::resize(name='" << m_name << "') not implemented";
398 }
std::string m_name
Definition: XrdFile.h:55
IOSize XrdFile::write ( const void *  from,
IOSize  n 
)
virtual

Write n bytes of data starting at address from.

Returns
The number of bytes written. Normally this will be n, but can be less, even zero, for example if the stream is non-blocking mode and cannot accept input at this time.
Exceptions
Incase of error, an exception is thrown. However if the stream is in non-blocking mode and cannot accept output, it will not throw an exception – the return value will be less than requested.

Implements IOOutput.

Definition at line 305 of file XrdFile.cc.

References edm::hlt::Exception, m_client, m_name, m_offset, m_stat, and asciidump::s.

306 {
307  if (n > 0x7fffffff)
308  throw cms::Exception("XrdFile::write()")
309  << "XrdFile::write(name='" << m_name << "', n=" << n
310  << ") too many bytes, limit is 0x7fffffff";
311 
312  ssize_t s = m_client->Write(from, m_offset, n);
313  if (s < 0)
314  throw cms::Exception("XrdFile::write()")
315  << "XrdFile::write(name='" << m_name << "', n=" << n
316  << ") failed with error '" << m_client->LastServerError()->errmsg
317  << "' (errno=" << m_client->LastServerError()->errnum << ")";
318 
319  m_offset += s;
320  if (m_offset > m_stat.size)
321  m_stat.size = m_offset;
322 
323  return s;
324 }
XrdClientStatInfo m_stat
Definition: XrdFile.h:53
IOOffset m_offset
Definition: XrdFile.h:52
XrdClient * m_client
Definition: XrdFile.h:51
std::string m_name
Definition: XrdFile.h:55
static std::string from(" from ")
string s
Definition: asciidump.py:422
IOSize XrdFile::write ( const void *  from,
IOSize  n,
IOOffset  pos 
)
virtual

Reimplemented from Storage.

Definition at line 327 of file XrdFile.cc.

References edm::hlt::Exception, m_client, m_name, m_stat, and asciidump::s.

328 {
329  if (n > 0x7fffffff)
330  throw cms::Exception("XrdFile::write()")
331  << "XrdFile::write(name='" << m_name << "', n=" << n
332  << ") too many bytes, limit is 0x7fffffff";
333 
334  ssize_t s = m_client->Write(from, pos, n);
335  if (s < 0)
336  throw cms::Exception("XrdFile::write()")
337  << "XrdFile::write(name='" << m_name << "', n=" << n
338  << ") failed with error '" << m_client->LastServerError()->errmsg
339  << "' (errno=" << m_client->LastServerError()->errnum << ")";
340 
341  if (pos + s > m_stat.size)
342  m_stat.size = pos + s;
343 
344  return s;
345 }
XrdClientStatInfo m_stat
Definition: XrdFile.h:53
XrdClient * m_client
Definition: XrdFile.h:51
std::string m_name
Definition: XrdFile.h:55
static std::string from(" from ")
string s
Definition: asciidump.py:422

Member Data Documentation

XrdClient* XrdFile::m_client
private

Definition at line 51 of file XrdFile.h.

Referenced by abort(), close(), open(), position(), prefetch(), read(), readv(), and write().

bool XrdFile::m_close
private

Definition at line 54 of file XrdFile.h.

Referenced by abort(), close(), open(), and ~XrdFile().

std::string XrdFile::m_name
private

Definition at line 55 of file XrdFile.h.

Referenced by close(), open(), read(), readv(), resize(), write(), and ~XrdFile().

IOOffset XrdFile::m_offset
private

Definition at line 52 of file XrdFile.h.

Referenced by abort(), close(), open(), position(), read(), readv(), and write().

XrdClientStatInfo XrdFile::m_stat
private

Definition at line 53 of file XrdFile.h.

Referenced by abort(), close(), open(), position(), and write().