X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fio%2Ffile.h;h=d34273477736c21efdd01335e75306b52f7ba990;hb=8091a3071918d4cd30f2b9ab903e1d73d12dcb36;hp=5fb0353211b2e99d23384afa2924e87ee78acc10;hpb=8642ac1b4478419630911a51a53fe8ef5fb46647;p=libs%2Fcore.git diff --git a/source/io/file.h b/source/io/file.h index 5fb0353..d342734 100644 --- a/source/io/file.h +++ b/source/io/file.h @@ -15,12 +15,14 @@ class file_not_found: public std::runtime_error { public: file_not_found(const std::string &fn): std::runtime_error(fn) { } + ~file_not_found() throw() { } }; class file_already_exists: public std::runtime_error { public: file_already_exists(const std::string &fn): std::runtime_error(fn) { } + ~file_already_exists() throw() { } }; @@ -50,6 +52,9 @@ public: write access is requested and the file does exist, it is created. Otherwise a missing file is an error. */ File(const std::string &, Mode = M_READ, CreateMode = C_OVERWRITE); +private: + void platform_init(const std::string &, CreateMode); +public: virtual ~File(); void set_block(bool); @@ -76,7 +81,29 @@ inline File::CreateMode operator&(File::CreateMode m, File::CreateMode n) inline File::CreateMode operator~(File::CreateMode m) { return File::CreateMode(~static_cast(m)); } -typedef Filtered BufferedFile; + +class BufferedFile: public Seekable +{ +private: + File file; + Buffered buffer; + SeekOffset position; + +public: + BufferedFile(const std::string &, Mode = M_READ, File::CreateMode = File::C_OVERWRITE); + +protected: + virtual unsigned do_write(const char *, unsigned); + virtual unsigned do_read(char *, unsigned); +public: + virtual unsigned put(char); + + virtual bool getline(std::string &); + virtual int get(); + + virtual SeekOffset seek(SeekOffset, SeekType); + virtual SeekOffset tell() const { return position; } +}; } // namespace IO } // namespace Msp