14 A class for reading and writing files.
16 Non-blocking mode is not supported on Win32.
18 class File: public Base
32 /** Creates a new file object and opens it. If the create flag is set and
33 write access is requested and the file does exist, it is created. Otherwise
34 a missing file is an error. */
35 File(const std::string &, Mode = M_READ, CreateMode = CreateMode(C_CREATE+C_TRUNCATE));
38 /** Closes the file. Any attempt to access the file after this will cause
39 an exception to be thrown. */
45 virtual unsigned do_write(const char *, unsigned);
46 virtual unsigned do_read(char *, unsigned);
51 /** Changes the read/write offset of the file. Returns the new offset. */
52 virtual int seek(int, SeekType);
54 /** Returns the current read/write offset of the file. */
55 virtual int tell() const;
57 virtual Handle get_event_handle() { return handle; }
60 void check_access(Mode) const;
63 inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)
64 { return File::CreateMode(static_cast<int>(m)|static_cast<int>(n)); }
66 inline File::CreateMode operator&(File::CreateMode m, File::CreateMode n)
67 { return File::CreateMode(static_cast<int>(m)&static_cast<int>(n)); }
69 inline File::CreateMode operator~(File::CreateMode m)
70 { return File::CreateMode(~static_cast<int>(m)); }
72 typedef Filtered<File, Buffered> BufferedFile;