14 class file_not_found: public std::runtime_error
17 file_not_found(const std::string &fn): std::runtime_error(fn) { }
18 ~file_not_found() throw() { }
21 class file_already_exists: public std::runtime_error
24 file_already_exists(const std::string &fn): std::runtime_error(fn) { }
25 ~file_already_exists() throw() { }
30 A class for reading and writing files.
32 Non-blocking mode is not supported on Win32.
34 class File: public Seekable
42 C_OVERWRITE = C_CREATE+C_TRUNCATE,
44 C_NEW = C_CREATE+C_EXCLUSIVE
51 /** Creates a new file object and opens it. If the create flag is set and
52 write access is requested and the file does exist, it is created. Otherwise
53 a missing file is an error. */
54 File(const std::string &, Mode = M_READ, CreateMode = C_OVERWRITE);
56 void platform_init(const std::string &, CreateMode);
63 virtual unsigned do_write(const char *, unsigned);
64 virtual unsigned do_read(char *, unsigned);
69 virtual SeekOffset seek(SeekOffset, SeekType);
70 virtual SeekOffset tell() const;
72 virtual const Handle &get_handle(Mode);
75 inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)
76 { return File::CreateMode(static_cast<int>(m)|static_cast<int>(n)); }
78 inline File::CreateMode operator&(File::CreateMode m, File::CreateMode n)
79 { return File::CreateMode(static_cast<int>(m)&static_cast<int>(n)); }
81 inline File::CreateMode operator~(File::CreateMode m)
82 { return File::CreateMode(~static_cast<int>(m)); }
85 class BufferedFile: public Seekable
93 BufferedFile(const std::string &, Mode = M_READ, File::CreateMode = File::C_OVERWRITE);
96 virtual unsigned do_write(const char *, unsigned);
97 virtual unsigned do_read(char *, unsigned);
99 virtual unsigned put(char);
101 virtual bool getline(std::string &);
104 virtual SeekOffset seek(SeekOffset, SeekType);
105 virtual SeekOffset tell() const { return position; }