14 class file_not_found: public std::runtime_error
17 file_not_found(const std::string &fn): std::runtime_error(fn) { }
20 class file_already_exists: public std::runtime_error
23 file_already_exists(const std::string &fn): std::runtime_error(fn) { }
28 A class for reading and writing files.
30 Non-blocking mode is not supported on Win32.
32 class File: public Seekable
40 C_OVERWRITE = C_CREATE+C_TRUNCATE,
42 C_NEW = C_CREATE+C_EXCLUSIVE
49 /** Creates a new file object and opens it. If the create flag is set and
50 write access is requested and the file does exist, it is created. Otherwise
51 a missing file is an error. */
52 File(const std::string &, Mode = M_READ, CreateMode = C_OVERWRITE);
58 virtual unsigned do_write(const char *, unsigned);
59 virtual unsigned do_read(char *, unsigned);
64 virtual SeekOffset seek(SeekOffset, SeekType);
65 virtual SeekOffset tell() const;
67 virtual const Handle &get_handle(Mode);
70 inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)
71 { return File::CreateMode(static_cast<int>(m)|static_cast<int>(n)); }
73 inline File::CreateMode operator&(File::CreateMode m, File::CreateMode n)
74 { return File::CreateMode(static_cast<int>(m)&static_cast<int>(n)); }
76 inline File::CreateMode operator~(File::CreateMode m)
77 { return File::CreateMode(~static_cast<int>(m)); }
79 typedef Filtered<File, Buffered> BufferedFile;