CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
File Class Reference

#include <File.h>

Inheritance diagram for File:
IOChannel Storage IOInput IOOutput IOInput IOOutput RemoteFile

Public Member Functions

virtual void abort (void)
 
virtual void attach (IOFD fd)
 
void close (void) override
 
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)
 
 File (const char *name, int flags=IOFlags::OpenRead, int perms=0666)
 
 File (const std::string &name, int flags=IOFlags::OpenRead, int perms=0666)
 
 File (IOFD fd, bool autoclose=true)
 
 File (void)
 
void flush (void) override
 
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)
 
IOOffset position (IOOffset offset, Relative whence=SET) override
 
virtual IOOffset position (IOOffset offset, Relative whence=SET)=0
 
virtual IOOffset position (void) const
 
bool prefetch (const IOPosBuffer *what, IOSize n) override
 
IOSize read (IOBuffer into, IOOffset pos)
 
IOSize read (void *into, IOSize n) override
 
virtual IOSize read (void *into, IOSize n, IOOffset pos)
 
IOSize read (void *into, IOSize n, IOOffset pos) override
 
IOSize readv (IOBuffer *into, IOSize length) override
 
virtual IOSize readv (IOPosBuffer *into, IOSize buffers)
 
void resize (IOOffset size) override
 
virtual void setAutoClose (bool closeit)
 
IOOffset size (void) const override
 
IOSize write (const void *from, IOSize n) override
 
virtual IOSize write (const void *from, IOSize n, IOOffset pos)
 
IOSize write (const void *from, IOSize n, IOOffset pos) override
 
IOSize write (IOBuffer from, IOOffset pos)
 
IOSize writev (const IOBuffer *from, IOSize length) override
 
virtual IOSize writev (const IOPosBuffer *from, IOSize buffers)
 
 ~File (void) override
 
- Public Member Functions inherited from IOChannel
virtual void fd (IOFD value)
 
virtual IOFD fd (void) const
 
 IOChannel (IOFD fd=-1)
 
virtual bool isBlocking (void) const
 
IOSize read (IOBuffer into)
 
IOSize read (void *into, IOSize n) override
 
virtual IOSize read (void *into, IOSize n)=0
 
int read (void)
 
IOSize readv (IOBuffer *into, IOSize buffers) override
 
virtual void setBlocking (bool value)
 
IOSize write (const void *from, IOSize n) override
 
virtual IOSize write (const void *from, IOSize n)=0
 
IOSize write (IOBuffer from)
 
IOSize write (unsigned char byte)
 
IOSize writev (const IOBuffer *from, IOSize buffers) override
 
 ~IOChannel (void) override
 
- Public Member Functions inherited from IOInput
IOSize read (IOBuffer into)
 
int read (void)
 
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 (IOBuffer from)
 
IOSize write (unsigned char byte)
 
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...
 
- Public Member Functions inherited from Storage
virtual bool eof (void) const
 
Storageoperator= (const Storage &)=delete
 
virtual IOOffset position (void) const
 
IOSize read (IOBuffer into)
 
IOSize read (IOBuffer into, IOOffset pos)
 
virtual IOSize read (void *into, IOSize n)=0
 
int read (void)
 
virtual IOSize readv (IOBuffer *into, IOSize buffers)
 
virtual IOSize readv (IOPosBuffer *into, IOSize buffers)
 
virtual void rewind (void)
 
 Storage (const Storage &)=delete
 
 Storage (void)
 
virtual IOSize write (const void *from, IOSize n)=0
 
IOSize write (IOBuffer from)
 
IOSize write (IOBuffer from, IOOffset pos)
 
IOSize write (unsigned char byte)
 
virtual IOSize writev (const IOBuffer *from, IOSize buffers)
 
virtual IOSize writev (const IOPosBuffer *from, IOSize buffers)
 
 ~Storage (void) override
 

Private Types

enum  { InternalAutoClose = 4096 }
 

Private Member Functions

Fileduplicate (bool copy) const
 
Fileduplicate (File *child) const
 
 File (IOFD fd, unsigned flags)
 

Static Private Member Functions

static bool sysclose (IOFD fd, int *error=nullptr)
 
static IOFD sysduplicate (IOFD fd)
 
static void sysopen (const char *name, int flags, int perms, IOFD &newfd, unsigned &newflags)
 

Private Attributes

unsigned m_flags
 

Additional Inherited Members

- Public Types inherited from Storage
enum  Relative { SET, CURRENT, END }
 
- Protected Member Functions inherited from IOChannel
bool sysclose (IOFD fd, int *error=nullptr)
 

Detailed Description

Basic file-related functions. Nicked from SEAL.

Definition at line 11 of file File.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
InternalAutoClose 

Definition at line 54 of file File.h.

54 { InternalAutoClose = 4096 }; //< Close on delete

Constructor & Destructor Documentation

◆ File() [1/5]

File::File ( void  )

Create a new file object without a file attached to it.

Definition at line 57 of file File.cc.

57  {
59  m_flags = 0;
60 }

References EDM_IOFD_INVALID, and ztee::fd.

◆ File() [2/5]

File::File ( IOFD  fd,
bool  autoclose = true 
)

Create a new file object from a file descriptor. The descriptor will be closed automatically when the file object is destructed if autoclose is true (the default).

Definition at line 65 of file File.cc.

65  {
66  this->fd(fd);
67  m_flags = autoclose ? InternalAutoClose : 0;
68 }

References ztee::fd.

◆ File() [3/5]

File::File ( const char *  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)

Create a new file object by calling open() with the given arguments.

Definition at line 77 of file File.cc.

77 { open(name, flags, perms); }

References HLT_FULL_cff::flags, and Skims_PA_cff::name.

◆ File() [4/5]

File::File ( const std::string &  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)

Create a new file object by calling open() with the given arguments.

Definition at line 80 of file File.cc.

80  {
81  open(name.c_str(), flags, perms);
82 }

References HLT_FULL_cff::flags, and Skims_PA_cff::name.

◆ ~File()

File::~File ( void  )
override

Release the resources held by the file object. If the object holds a valid file descriptor given to it through the constructor or obtained by calling open(), the descriptor will be closed.

Definition at line 87 of file File.cc.

87  {
89  abort();
90 }

◆ File() [5/5]

File::File ( IOFD  fd,
unsigned  flags 
)
private

Internal function for copying file objects to retain the state flags.

Definition at line 71 of file File.cc.

71  {
72  this->fd(fd);
73  m_flags = flags;
74 }

References ztee::fd, and HLT_FULL_cff::flags.

Member Function Documentation

◆ abort()

void File::abort ( void  )
virtual

Close the file and ignore all errors.

Reimplemented in RemoteFile.

Definition at line 254 of file File.cc.

254  {
255  IOFD fd = this->fd();
256  if (fd != EDM_IOFD_INVALID) {
257  sysclose(fd);
259  this->fd(EDM_IOFD_INVALID);
260  }
261 }

References EDM_IOFD_INVALID, and ztee::fd.

Referenced by RemoteFile::abort().

◆ attach()

void File::attach ( IOFD  fd)
virtual

Definition at line 178 of file File.cc.

178  {
179  this->fd(fd);
180  m_flags = 0;
181 }

References ztee::fd.

◆ close()

void File::close ( void  )
overridevirtual

Close the file.

Reimplemented from IOChannel.

Reimplemented in RemoteFile.

Definition at line 241 of file File.cc.

241  {
242  IOFD fd = this->fd();
243  assert(fd != EDM_IOFD_INVALID);
244 
245  int error;
246  if (!sysclose(fd, &error))
247  throwStorageError("FileCloseError", "Calling File::close()", "sysclose", error);
248 
250  this->fd(EDM_IOFD_INVALID);
251 }

References cms::cuda::assert(), EDM_IOFD_INVALID, relativeConstraints::error, ztee::fd, and throwStorageError().

Referenced by RemoteFile::close(), esMonitoring.AsyncLineReaderMixin::handle_close(), and esMonitoring.FDJsonServer::handle_close().

◆ create() [1/2]

void File::create ( const char *  name,
bool  exclusive = false,
int  perms = 0666 
)
virtual

Create and open the file name in write mode. If exclusive, the creation fails if the file already exists, otherwise if the file exists, it will be truncated. The new file will have the permissions perms.

Definition at line 131 of file File.cc.

131  {
133 }

References generator_cfi::exclusive, Skims_PA_cff::name, IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenTruncate, and IOFlags::OpenWrite.

◆ create() [2/2]

void File::create ( const std::string &  name,
bool  exclusive = false,
int  perms = 0666 
)
virtual

Create and open the file name in write mode. If exclusive, the creation fails if the file already exists, otherwise if the file exists, it will be truncated. The new file will have the permissions perms.

Definition at line 139 of file File.cc.

139  {
140  open(name.c_str(), (OpenCreate | OpenWrite | OpenTruncate | (exclusive ? OpenExclusive : 0)), perms);
141 }

References generator_cfi::exclusive, Skims_PA_cff::name, IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenTruncate, and IOFlags::OpenWrite.

◆ duplicate() [1/2]

File * File::duplicate ( bool  copy) const
private

Duplicate the file object. If copy, also duplicates the underlying file descriptor, otherwise the two will point to the same descriptor. If the file descriptor is not copied, the copy will not close its file descriptor on destruction, the original object (this) will.

Definition at line 110 of file File.cc.

110  {
111  File *dup = new File(fd(), copy ? m_flags : 0);
112  return copy ? this->duplicate(dup) : dup;
113 }

References filterCSVwithJSON::copy, trackingPlots::dup, ztee::fd, and VtxSmearedBeamProfile_cfi::File.

◆ duplicate() [2/2]

File * File::duplicate ( File child) const
private

Internal implementation of duplicate() to actually duplicate the file handle into child.

Definition at line 117 of file File.cc.

117  {
118  IOFD fd = this->fd();
119  assert(fd != EDM_IOFD_INVALID);
120  assert(child);
121  child->fd(sysduplicate(fd));
122  child->m_flags = m_flags;
123  return child;
124 }

References cms::cuda::assert(), submitPVValidationJobs::child, EDM_IOFD_INVALID, and ztee::fd.

◆ flush()

void File::flush ( void  )
overridevirtual

Flush the system's file system buffers for this file.

Reimplemented from Storage.

Definition at line 122 of file UnixFile.cc.

122  {
123  IOFD fd = this->fd();
124  assert(fd != EDM_IOFD_INVALID);
125 
126 #if _POSIX_SYNCHRONIZED_IO > 0
127  if (fdatasync(fd) == -1)
128  throwStorageError("FileFlushError", "Calling File::flush()", "fdatasync()", errno);
129 #elif _POSIX_FSYNC > 0
130  if (fsync(fd) == -1)
131  throwStorageError("FileFlushError", "Calling File::flush()", "fsync()", errno);
132 #endif
133 }

References cms::cuda::assert(), EDM_IOFD_INVALID, ztee::fd, and throwStorageError().

◆ open() [1/2]

void File::open ( const char *  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)
virtual

Open or possibly create the file name with options specified in flags. If the file is to be created, it will be given the permissions perms. If this object already has a file open, it is closed first.

Definition at line 156 of file File.cc.

156  {
157  // is zero and always implied. OTOH, existence check should be
158  // done with Filename::exists() -- see comments there about what
159  // can happen on a WIN32 remote share even if the file doesn't
160  // exist. For now make sure that read or write was asked for.
161 
162  assert(name && *name);
164 
165  // If I am already open, close the old file first.
167  close();
168 
169  IOFD newfd = EDM_IOFD_INVALID;
170  unsigned newflags = InternalAutoClose;
171 
172  sysopen(name, flags, perms, newfd, newflags);
173 
174  fd(newfd);
175  m_flags = newflags;
176 }

References cms::cuda::assert(), EDM_IOFD_INVALID, ztee::fd, HLT_FULL_cff::flags, Skims_PA_cff::name, IOFlags::OpenRead, and IOFlags::OpenWrite.

◆ open() [2/2]

void File::open ( const std::string &  name,
int  flags = IOFlags::OpenRead,
int  perms = 0666 
)
virtual

Open or possibly create the file name with options specified in flags. If the file is to be created, it will be given the permissions perms. If this object already has a file open, it is closed first. Redirected to the overloaded method taking a "const char *" argument.

Definition at line 148 of file File.cc.

148  {
149  open(name.c_str(), flags, perms);
150 }

References HLT_FULL_cff::flags, and Skims_PA_cff::name.

◆ position() [1/3]

IOOffset File::position ( IOOffset  offset,
Relative  whence = SET 
)
overridevirtual

Return the current file pointer position.

Implements Storage.

Definition at line 101 of file UnixFile.cc.

101  {
102  IOFD fd = this->fd();
103  assert(fd != EDM_IOFD_INVALID);
104  assert(whence == CURRENT || whence == SET || whence == END);
105 
107  int mywhence = (whence == SET ? SEEK_SET : whence == CURRENT ? SEEK_CUR : SEEK_END);
108  if ((result = ::lseek(fd, offset, mywhence)) == -1)
109  throwStorageError("FilePositionError", "Calling File::position()", "lseek()", errno);
110 
111  return result;
112 }

References cms::cuda::assert(), EDM_IOFD_INVALID, ztee::fd, hltrates_dqm_sourceclient-live_cfg::offset, mps_fire::result, L1DTConfigBti_cff::SET, and throwStorageError().

◆ position() [2/3]

virtual IOOffset Storage::position

◆ position() [3/3]

IOOffset Storage::position

Definition at line 72 of file Storage.cc.

72  {
73  Storage *self = const_cast<Storage *>(this);
74  return self->position(0, CURRENT);
75 }

◆ prefetch()

bool File::prefetch ( const IOPosBuffer what,
IOSize  n 
)
overridevirtual

Prefetch data for the file.

Reimplemented from Storage.

Definition at line 185 of file File.cc.

185  {
186  IOFD fd = this->fd();
187  for (IOSize i = 0; i < n; ++i) {
188 #if F_RDADVISE
189  radvisory info;
190  info.ra_offset = what[i].offset();
191  info.ra_count = what[i].size();
192  fcntl(fd, F_RDADVISE, &info);
193 #elif _POSIX_ADVISORY_INFO > 0
194  posix_fadvise(fd, what[i].offset(), what[i].size(), POSIX_FADV_WILLNEED);
195 #else
196 #error advisory read ahead not available on this platform
197 #endif
198  }
199  return true;
200 }

References ztee::fd, mps_fire::i, info(), dqmiodumpmetadata::n, IOPosBuffer::offset(), hltrates_dqm_sourceclient-live_cfg::offset, IOPosBuffer::size(), and findQualityFiles::size.

◆ read() [1/4]

IOSize Storage::read

Definition at line 10 of file Storage.cc.

10 { return read(into.data(), into.size(), pos); }

◆ read() [2/4]

IOSize File::read ( void *  into,
IOSize  n 
)
overridevirtual

Read from the file.

Implements IOInput.

Definition at line 203 of file File.cc.

203 { return IOChannel::read(into, n); }

References dqmiodumpmetadata::n, and IOInput::read().

◆ read() [3/4]

IOSize Storage::read

Definition at line 12 of file Storage.cc.

12  {
13  // FIXME: this is not thread safe! split into separate interface
14  // that a particular storage can choose to support or not? make
15  // sure that throw semantics are correct here!
16  // FIXME: use saveposition object in case exceptions are thrown?
17  IOOffset here = position();
18  position(pos);
19  n = read(into, n);
20  position(here);
21  return n;
22 }

◆ read() [4/4]

IOSize File::read ( void *  into,
IOSize  n,
IOOffset  pos 
)
overridevirtual

Reimplemented from Storage.

Definition at line 58 of file UnixFile.cc.

58  {
59  assert(pos >= 0);
60 
61  ssize_t s;
62  do
63  s = ::pread(fd(), into, n, pos);
64  while (s == -1 && errno == EINTR);
65 
66  if (s == -1)
67  throwStorageError(edm::errors::FileReadError, "Calling File::read()", "pread()", errno);
68 
69  return s;
70 }

References cms::cuda::assert(), ztee::fd, edm::errors::FileReadError, dqmiodumpmetadata::n, alignCSCRings::s, and throwStorageError().

◆ readv() [1/2]

IOSize File::readv ( IOBuffer into,
IOSize  length 
)
overridevirtual

Read from the file.

Reimplemented from IOInput.

Definition at line 206 of file File.cc.

206 { return IOChannel::readv(into, length); }

References IOChannel::readv().

◆ readv() [2/2]

IOSize Storage::readv

Definition at line 24 of file Storage.cc.

24  {
25  IOOffset here = position();
26  IOSize total = 0;
27  for (IOSize i = 0; i < n; ++i) {
28  try {
29  position(into[i].offset());
30  total += read(into[i].data(), into[i].size());
31  } catch (cms::Exception &) {
32  if (!total)
33  throw;
34  break;
35  }
36  }
37  position(here);
38  return total;
39 }

◆ resize()

void File::resize ( IOOffset  size)
overridevirtual

Resize to the file to size. If size is less than the file's current size, the file is truncated. If size is larger than the file's current size, the file is extended with zero bytes. Does not change the current file pointer.

Implements Storage.

Definition at line 114 of file UnixFile.cc.

114  {
115  IOFD fd = this->fd();
116  assert(fd != EDM_IOFD_INVALID);
117 
118  if (ftruncate(fd, size) == -1)
119  throwStorageError("FileResizeError", "Calling File::resize()", "ftruncate()", errno);
120 }

References cms::cuda::assert(), EDM_IOFD_INVALID, ztee::fd, findQualityFiles::size, and throwStorageError().

◆ setAutoClose()

void File::setAutoClose ( bool  autoclose)
virtual

Set the autoclose flag of the file. If autoclose is true, the destructor will automatically try to close the underlying file descriptor. Otherwise the file descriptor will be left open. Set the flag off if the file descriptor is originally owned by someone else.

Definition at line 98 of file File.cc.

98  {
100  if (autoclose)
102 }

◆ size()

IOOffset File::size ( void  ) const
overridevirtual

Get the size of the file.

Reimplemented from Storage.

Definition at line 90 of file UnixFile.cc.

90  {
91  IOFD fd = this->fd();
92  assert(fd != EDM_IOFD_INVALID);
93 
94  struct stat info;
95  if (fstat(fd, &info) == -1)
96  throwStorageError("FileSizeError", "Calling File::size()", "fstat()", errno);
97 
98  return info.st_size;
99 }

References cms::cuda::assert(), EDM_IOFD_INVALID, ztee::fd, info(), edm_modernize_messagelogger::stat, and throwStorageError().

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

◆ sysclose()

bool File::sysclose ( IOFD  fd,
int *  error = nullptr 
)
staticprivate

Actually close a file handle and return error code.

Definition at line 135 of file UnixFile.cc.

135  {
136  int ret = ::close(fd);
137  if (error)
138  *error = errno;
139  return ret != -1;
140 }

References relativeConstraints::error, ztee::fd, and runTheMatrix::ret.

◆ sysduplicate()

IOFD File::sysduplicate ( IOFD  fd)
staticprivate

Definition at line 9 of file UnixFile.cc.

9  {
10  IOFD copyfd;
11  if ((copyfd = ::dup(fd)) == EDM_IOFD_INVALID)
12  throwStorageError("FileDuplicateError", "Calling File::sysduplicate()", "dup()", errno);
13 
14  return copyfd;
15 }

References EDM_IOFD_INVALID, ztee::fd, and throwStorageError().

◆ sysopen()

void File::sysopen ( const char *  name,
int  flags,
int  perms,
IOFD newfd,
unsigned &  newflags 
)
staticprivate

Definition at line 17 of file UnixFile.cc.

17  {
18  // Translate our flags to system flags.
19  int openflags = 0;
20 
21  if ((flags & OpenRead) && (flags & OpenWrite))
22  openflags |= O_RDWR;
23  else if (flags & OpenRead)
24  openflags |= O_RDONLY;
25  else if (flags & OpenWrite)
26  openflags |= O_WRONLY;
27 
28  if (flags & OpenNonBlock)
29  openflags |= O_NONBLOCK;
30 
31  if (flags & OpenAppend)
32  openflags |= O_APPEND;
33 
34 #ifdef O_SYNC
35  if (flags & OpenUnbuffered)
36  openflags |= O_SYNC;
37 #else
38  if (flags & OpenUnbuffered)
39  newflags |= OpenUnbuffered;
40 #endif
41 
42  if (flags & OpenCreate)
43  openflags |= O_CREAT;
44 
45  if (flags & OpenExclusive)
46  openflags |= O_EXCL;
47 
48  if (flags & OpenTruncate)
49  openflags |= O_TRUNC;
50 
51  if (flags & OpenNotCTTY)
52  openflags |= O_NOCTTY;
53 
54  if ((newfd = ::open(name, openflags, perms)) == -1)
55  throwStorageError(edm::errors::FileOpenError, "Calling File::sysopen()", "open()", errno);
56 }

References edm::errors::FileOpenError, HLT_FULL_cff::flags, Skims_PA_cff::name, O_NONBLOCK, IOFlags::OpenAppend, IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenNonBlock, IOFlags::OpenNotCTTY, IOFlags::OpenRead, IOFlags::OpenTruncate, IOFlags::OpenUnbuffered, IOFlags::OpenWrite, and throwStorageError().

◆ write() [1/4]

IOSize File::write ( const void *  from,
IOSize  n 
)
overridevirtual

Write to the file.

Implements IOOutput.

Definition at line 209 of file File.cc.

209  {
210  // FIXME: This may create a race condition or cause trouble on
211  // remote files. Should be currently needed only on WIN32.
212  if (m_flags & OpenAppend)
213  position(0, END);
214 
215  IOSize s = IOChannel::write(from, n);
216 
217  if (m_flags & OpenUnbuffered)
218  // FIXME: Exception handling?
219  flush();
220 
221  return s;
222 }

References dqmiodumpmetadata::n, IOFlags::OpenAppend, IOFlags::OpenUnbuffered, position, alignCSCRings::s, and IOChannel::write().

◆ write() [2/4]

IOSize Storage::write

Definition at line 44 of file Storage.cc.

44  {
45  // FIXME: this is not thread safe! split into separate interface
46  // that a particular storage can choose to support or not? make
47  // sure that throw semantics are correct here!
48 
49  // FIXME: use saveposition object in case exceptions are thrown?
50  IOOffset here = position();
51  position(pos);
52  n = write(from, n);
53  position(here);
54  return n;
55 }

◆ write() [3/4]

IOSize File::write ( const void *  from,
IOSize  n,
IOOffset  pos 
)
overridevirtual

Reimplemented from Storage.

Definition at line 72 of file UnixFile.cc.

72  {
73  assert(pos >= 0);
74 
75  ssize_t s;
76  do
77  s = ::pwrite(fd(), from, n, pos);
78  while (s == -1 && errno == EINTR);
79 
80  if (s == -1)
81  throwStorageError(edm::errors::FileWriteError, "Calling File::write()", "pwrite()", errno);
82 
83  if (m_flags & OpenUnbuffered)
84  // FIXME: Exception handling?
85  flush();
86 
87  return s;
88 }

References cms::cuda::assert(), ztee::fd, edm::errors::FileWriteError, dqmiodumpmetadata::n, IOFlags::OpenUnbuffered, alignCSCRings::s, and throwStorageError().

◆ write() [4/4]

IOSize Storage::write

Definition at line 42 of file Storage.cc.

42 { return write(from.data(), from.size(), pos); }

◆ writev() [1/2]

IOSize File::writev ( const IOBuffer from,
IOSize  length 
)
overridevirtual

Write to the file.

Reimplemented from IOOutput.

Definition at line 225 of file File.cc.

225  {
226  // FIXME: This may create a race condition or cause trouble on
227  // remote files. Should be currently needed only on WIN32.
228  if (m_flags & OpenAppend)
229  position(0, END);
230 
231  IOSize s = IOChannel::writev(from, length);
232 
233  if (m_flags & OpenUnbuffered)
234  // FIXME: Exception handling?
235  flush();
236 
237  return s;
238 }

References IOFlags::OpenAppend, IOFlags::OpenUnbuffered, position, alignCSCRings::s, and IOChannel::writev().

◆ writev() [2/2]

IOSize Storage::writev

Definition at line 57 of file Storage.cc.

57  {
58  IOSize total = 0;
59  for (IOSize i = 0; i < n; ++i) {
60  try {
61  total += write(from[i].data(), from[i].size(), from[i].offset());
62  } catch (cms::Exception &) {
63  if (!total)
64  throw;
65  break;
66  }
67  }
68  return total;
69 }

Member Data Documentation

◆ m_flags

unsigned File::m_flags
private

Definition at line 64 of file File.h.

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
File::open
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: File.cc:156
IOChannel::readv
IOSize readv(IOBuffer *into, IOSize buffers) override
Definition: UnixIOChannel.cc:21
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
IOFlags::OpenNonBlock
Definition: IOFlags.h:9
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
File::flush
void flush(void) override
Definition: UnixFile.cc:122
File::duplicate
File * duplicate(bool copy) const
Definition: File.cc:110
File::close
void close(void) override
Definition: File.cc:241
pos
Definition: PixelAliasList.h:18
Storage::END
Definition: Storage.h:22
Storage::SET
Definition: Storage.h:22
edm::errors::FileWriteError
Definition: EDMException.h:66
cms::cuda::assert
assert(be >=bs)
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
IOFlags::OpenTruncate
Definition: IOFlags.h:28
IOFlags::OpenWrite
Definition: IOFlags.h:8
relativeConstraints.error
error
Definition: relativeConstraints.py:53
edm::errors::FileOpenError
Definition: EDMException.h:49
alignCSCRings.s
s
Definition: alignCSCRings.py:92
IOChannel::writev
IOSize writev(const IOBuffer *from, IOSize buffers) override
Definition: UnixIOChannel.cc:65
File
Definition: File.h:11
IOFlags::OpenRead
Definition: IOFlags.h:7
trackingPlots.dup
dup
Definition: trackingPlots.py:183
File::m_flags
unsigned m_flags
Definition: File.h:64
IOOffset
int64_t IOOffset
Definition: IOTypes.h:19
File::InternalAutoClose
Definition: File.h:54
IOFlags::OpenNotCTTY
Definition: IOFlags.h:30
throwStorageError
void throwStorageError(const char *category, const char *context, const char *call, int error)
Definition: Throw.cc:6
IOFlags::OpenExclusive
Definition: IOFlags.h:25
IOFlags::OpenCreate
Definition: IOFlags.h:24
File::sysopen
static void sysopen(const char *name, int flags, int perms, IOFD &newfd, unsigned &newflags)
Definition: UnixFile.cc:17
File::write
IOSize write(const void *from, IOSize n) override
Definition: File.cc:209
IOFD
int IOFD
Definition: IOTypes.h:22
IOFlags::OpenAppend
Definition: IOFlags.h:18
IOPosBuffer::size
IOSize size(void) const
Definition: IOPosBuffer.h:45
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
generator_cfi.exclusive
exclusive
Definition: generator_cfi.py:24
EDM_IOFD_INVALID
#define EDM_IOFD_INVALID
Definition: IOTypes.h:8
IOPosBuffer::offset
IOOffset offset(void) const
Definition: IOPosBuffer.h:39
File::size
IOOffset size(void) const override
Definition: UnixFile.cc:90
Storage::position
virtual IOOffset position(void) const
Definition: Storage.cc:72
IOChannel::write
IOSize write(const void *from, IOSize n) override
Definition: UnixIOChannel.cc:53
IOInput::read
int read(void)
Definition: IOInput.cc:52
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
O_NONBLOCK
#define O_NONBLOCK
Definition: SysFile.h:21
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
Storage::CURRENT
Definition: Storage.h:22
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
IOChannel::fd
virtual IOFD fd(void) const
Definition: IOChannel.cc:69
IOFlags::OpenUnbuffered
Definition: IOFlags.h:20
mps_fire.result
result
Definition: mps_fire.py:311
cms::Exception
Definition: Exception.h:70
File::abort
virtual void abort(void)
Definition: File.cc:254
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
IOSize
size_t IOSize
Definition: IOTypes.h:14
HLT_FULL_cff.flags
flags
Definition: HLT_FULL_cff.py:13168
Storage
Definition: Storage.h:20
child
Definition: simpleInheritance.h:11
File::sysduplicate
static IOFD sysduplicate(IOFD fd)
Definition: UnixFile.cc:9
edm::errors::FileReadError
Definition: EDMException.h:50
File::sysclose
static bool sysclose(IOFD fd, int *error=nullptr)
Definition: UnixFile.cc:135
File::File
File(void)
Definition: File.cc:57