X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Ffile.h;h=16f2dcbe4b5490da384006982f56be6dbc728065;hb=73a21b6f495e16707ede460a2c9d8f1474bb4d93;hp=49b596bb943077411db57b0bc66044de8de87a92;hpb=c0861d1f8e3869f058bc8b152cd35a08e5b03e73;p=libs%2Fcore.git diff --git a/source/file.h b/source/file.h index 49b596b..16f2dcb 100644 --- a/source/file.h +++ b/source/file.h @@ -9,6 +9,8 @@ Distributed under the LGPL #include #include "base.h" +#include "buffered.h" +#include "filtered.h" #include "seek.h" namespace Msp { @@ -24,42 +26,44 @@ class File: public Base public: enum CreateMode { - C_NONE=0, - C_CREATE=1, - C_TRUNCATE=2 + C_NONE = 0, + C_CREATE = 1, + C_TRUNCATE = 2 }; - File(const std::string &, Mode=M_READ, CreateMode =CreateMode(C_CREATE+C_TRUNCATE)); + File(const std::string &, Mode = M_READ, CreateMode =CreateMode(C_CREATE+C_TRUNCATE)); void close(); void set_block(bool); - void enable_events(); - void sync(); + virtual void sync(); - int seek(int, SeekType); - int tell() const; + virtual int seek(int, SeekType); + virtual int tell() const; - Handle get_event_handle() { return handle; } + virtual Handle get_event_handle() { return handle; } - ~File(); + virtual ~File(); private: Handle handle; - void check_access(Mode) const; - unsigned do_write(const char *, unsigned); - unsigned do_read(char *, unsigned); + void check_access(Mode) const; +protected: + virtual unsigned do_write(const char *, unsigned); + virtual unsigned do_read(char *, unsigned); }; inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n) -{ return File::CreateMode((int)m|(int)n); } +{ return File::CreateMode(static_cast(m)|static_cast(n)); } inline File::CreateMode operator&(File::CreateMode m, File::CreateMode n) -{ return File::CreateMode((int)m&(int)n); } +{ return File::CreateMode(static_cast(m)&static_cast(n)); } inline File::CreateMode operator~(File::CreateMode m) -{ return File::CreateMode(~(int)m); } +{ return File::CreateMode(~static_cast(m)); } + +typedef Filtered BufferedFile; } // namespace IO } // namespace Msp