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::write;
38  using Storage::position;
39 
40  virtual bool prefetch (const IOPosBuffer *what, IOSize n);
41  virtual IOSize read (void *into, IOSize n);
42  virtual IOSize read (void *into, IOSize n, IOOffset pos);
43  virtual IOSize readv (IOBuffer *into, IOSize length);
44 
45  virtual IOSize write (const void *from, IOSize n);
46  virtual IOSize write (const void *from, IOSize n, IOOffset pos);
47  virtual IOSize writev (const IOBuffer *from, IOSize length);
48 
49  virtual IOOffset size (void) const;
50  virtual IOOffset position (IOOffset offset, Relative whence = SET);
51 
52  virtual void resize (IOOffset size);
53 
54  virtual void flush (void);
55  virtual void close (void);
56  virtual void abort (void);
57 
58  virtual void setAutoClose (bool closeit);
59 
60 private:
61  enum { InternalAutoClose = 4096 }; //< Close on delete
62 
63  File (IOFD fd, unsigned flags);
64 
65  File * duplicate (bool copy) const;
66  File * duplicate (File *child) const;
67  static IOFD sysduplicate (IOFD fd);
68  static void sysopen (const char *name, int flags, int perms,
69  IOFD &newfd, unsigned &newflags);
70  static bool sysclose (IOFD fd, int *error = 0);
71 
72  unsigned m_flags;
73 };
74 
75 #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:72
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