test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
13 public:
14  File (void);
15  File (IOFD fd, bool autoclose = true);
16  File (const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
17  File (const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
18  ~File (void);
19  // implicit copy constructor
20  // implicit assignment operator
21 
22  virtual void create (const char *name,
23  bool exclusive = false,
24  int perms = 0666);
25  virtual void create (const std::string &name,
26  bool exclusive = false,
27  int perms = 0666);
28  virtual void open (const char *name,
30  int perms = 0666);
31  virtual void open (const std::string &name,
33  int perms = 0666);
34  virtual void attach (IOFD fd);
35 
36  using Storage::read;
37  using Storage::readv;
38  using Storage::write;
39  using Storage::writev;
40  using Storage::position;
41 
42  virtual bool prefetch (const IOPosBuffer *what, IOSize n);
43  virtual IOSize read (void *into, IOSize n);
44  virtual IOSize read (void *into, IOSize n, IOOffset pos);
45  virtual IOSize readv (IOBuffer *into, IOSize length);
46 
47  virtual IOSize write (const void *from, IOSize n);
48  virtual IOSize write (const void *from, IOSize n, IOOffset pos);
49  virtual IOSize writev (const IOBuffer *from, IOSize length);
50 
51  virtual IOOffset size (void) const;
52  virtual IOOffset position (IOOffset offset, Relative whence = SET);
53 
54  virtual void resize (IOOffset size);
55 
56  virtual void flush (void);
57  virtual void close (void);
58  virtual void abort (void);
59 
60  virtual void setAutoClose (bool closeit);
61 
62 private:
63  enum { InternalAutoClose = 4096 }; //< Close on delete
64 
65  File (IOFD fd, unsigned flags);
66 
67  File * duplicate (bool copy) const;
68  File * duplicate (File *child) const;
69  static IOFD sysduplicate (IOFD fd);
70  static void sysopen (const char *name, int flags, int perms,
71  IOFD &newfd, unsigned &newflags);
72  static bool sysclose (IOFD fd, int *error = 0);
73 
74  unsigned m_flags;
75 };
76 
77 #endif // STORAGE_FACTORY_FILE_H
virtual IOSize readv(IOBuffer *into, IOSize length)
Definition: File.cc:236
virtual void setAutoClose(bool closeit)
Definition: File.cc:103
static bool sysclose(IOFD fd, int *error=0)
Definition: UnixFile.cc:155
unsigned m_flags
Definition: File.h:74
virtual IOSize readv(IOPosBuffer *into, IOSize buffers)
Definition: Storage.cc:31
static void sysopen(const char *name, int flags, int perms, IOFD &newfd, unsigned &newflags)
Definition: UnixFile.cc:20
~File(void)
Definition: File.cc:90
virtual void create(const char *name, bool exclusive=false, int perms=0666)
Definition: File.cc:142
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
virtual void attach(IOFD fd)
Definition: File.cc:201
virtual IOOffset size(void) const
Definition: UnixFile.cc:100
virtual bool prefetch(const IOPosBuffer *what, IOSize n)
Definition: File.cc:210
Relative
Definition: Storage.h:23
virtual void open(const char *name, int flags=IOFlags::OpenRead, int perms=0666)
Definition: File.cc:177
virtual IOSize write(const void *from, IOSize n, IOOffset pos)
Definition: Storage.cc:59
virtual void abort(void)
Definition: File.cc:293
virtual IOSize writev(const IOBuffer *from, IOSize length)
Definition: File.cc:259
virtual IOOffset position(void) const
Definition: Storage.cc:95
File(void)
Definition: File.cc:57
virtual void flush(void)
Definition: UnixFile.cc:140
static IOFD sysduplicate(IOFD fd)
Definition: UnixFile.cc:10
int read(void)
Definition: IOInput.cc:54
virtual IOSize write(const void *from, IOSize n)
Definition: File.cc:241
int64_t IOOffset
Definition: IOTypes.h:19
virtual void resize(IOOffset size)
Definition: UnixFile.cc:130
int IOFD
Definition: IOTypes.h:22
File * duplicate(bool copy) const
Definition: File.cc:117
size_t IOSize
Definition: IOTypes.h:14
virtual IOFD fd(void) const
Definition: IOChannel.cc:73
Definition: File.h:11
virtual void close(void)
Definition: File.cc:277
virtual IOSize writev(const IOPosBuffer *from, IOSize buffers)
Definition: Storage.cc:74