CMS 3D CMS Logo

File.h
Go to the documentation of this file.
1 #ifndef STORAGE_FACTORY_FILE_H
2 #define STORAGE_FACTORY_FILE_H
3 
8 #include <string>
9 
11 class File : public IOChannel, public Storage {
12 public:
13  File(void);
14  File(IOFD fd, bool autoclose = true);
15  File(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
16  File(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
17  ~File(void) override;
18  // implicit copy constructor
19  // implicit assignment operator
20 
21  virtual void create(const char *name, bool exclusive = false, int perms = 0666);
22  virtual void create(const std::string &name, bool exclusive = false, int perms = 0666);
23  virtual void open(const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
24  virtual void open(const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
25  virtual void attach(IOFD fd);
26 
27  using Storage::position;
28  using Storage::read;
29  using Storage::readv;
30  using Storage::write;
31  using Storage::writev;
32 
33  bool prefetch(const IOPosBuffer *what, IOSize n) override;
34  IOSize read(void *into, IOSize n) override;
35  IOSize read(void *into, IOSize n, IOOffset pos) override;
36  IOSize readv(IOBuffer *into, IOSize length) override;
37 
38  IOSize write(const void *from, IOSize n) override;
39  IOSize write(const void *from, IOSize n, IOOffset pos) override;
40  IOSize writev(const IOBuffer *from, IOSize length) override;
41 
42  IOOffset size(void) const override;
43  IOOffset position(IOOffset offset, Relative whence = SET) override;
44 
45  void resize(IOOffset size) override;
46 
47  void flush(void) override;
48  void close(void) override;
49  virtual void abort(void);
50 
51  virtual void setAutoClose(bool closeit);
52 
53 private:
54  enum { InternalAutoClose = 4096 }; //< Close on delete
55 
56  File(IOFD fd, unsigned flags);
57 
58  File *duplicate(bool copy) const;
59  File *duplicate(File *child) const;
60  static IOFD sysduplicate(IOFD fd);
61  static void sysopen(const char *name, int flags, int perms, IOFD &newfd, unsigned &newflags);
62  static bool sysclose(IOFD fd, int *error = nullptr);
63 
64  unsigned m_flags;
65 };
66 
67 #endif // STORAGE_FACTORY_FILE_H
File::open
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: File.cc:156
File::~File
~File(void) override
Definition: File.cc:87
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
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::SET
Definition: Storage.h:22
Storage::Relative
Relative
Definition: Storage.h:22
File::resize
void resize(IOOffset size) override
Definition: UnixFile.cc:114
Storage.h
Storage::readv
virtual IOSize readv(IOPosBuffer *into, IOSize buffers)
Definition: Storage.cc:24
relativeConstraints.error
error
Definition: relativeConstraints.py:53
File
Definition: File.h:11
IOFlags.h
File::prefetch
bool prefetch(const IOPosBuffer *what, IOSize n) override
Definition: File.cc:185
IOFlags::OpenRead
Definition: IOFlags.h:7
File::writev
IOSize writev(const IOBuffer *from, IOSize length) override
Definition: File.cc:225
File::m_flags
unsigned m_flags
Definition: File.h:64
IOBuffer
Definition: IOBuffer.h:7
File::setAutoClose
virtual void setAutoClose(bool closeit)
Definition: File.cc:98
IOOffset
int64_t IOOffset
Definition: IOTypes.h:19
File::InternalAutoClose
Definition: File.h:54
File::attach
virtual void attach(IOFD fd)
Definition: File.cc:178
IOTypes.h
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
IOChannel
Definition: IOChannel.h:9
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IOFD
int IOFD
Definition: IOTypes.h:22
generator_cfi.exclusive
exclusive
Definition: generator_cfi.py:24
Storage::writev
virtual IOSize writev(const IOPosBuffer *from, IOSize buffers)
Definition: Storage.cc:57
File::size
IOOffset size(void) const override
Definition: UnixFile.cc:90
Storage::position
virtual IOOffset position(void) const
Definition: Storage.cc:72
IOInput::read
int read(void)
Definition: IOInput.cc:52
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
File::create
virtual void create(const char *name, bool exclusive=false, int perms=0666)
Definition: File.cc:131
IOChannel::fd
virtual IOFD fd(void) const
Definition: IOChannel.cc:69
IOPosBuffer
Definition: IOPosBuffer.h:7
File::readv
IOSize readv(IOBuffer *into, IOSize length) override
Definition: File.cc:206
File::abort
virtual void abort(void)
Definition: File.cc:254
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
IOChannel.h
Storage::write
virtual IOSize write(const void *from, IOSize n, IOOffset pos)
Definition: Storage.cc:44
File::sysclose
static bool sysclose(IOFD fd, int *error=nullptr)
Definition: UnixFile.cc:135
File::File
File(void)
Definition: File.cc:57