X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Ffile.h;h=430571f909d872854e64d11ac43917442541f121;hp=05aaf9565a08653f278773e010fee4acb6361779;hb=f041a31f9a6e19da86a63912e5a8050f216e5bc5;hpb=6e0fd758970bcb5bad5e3f2454b694cc4d7b4b66 diff --git a/source/io/file.h b/source/io/file.h index 05aaf95..430571f 100644 --- a/source/io/file.h +++ b/source/io/file.h @@ -1,21 +1,29 @@ #ifndef MSP_IO_FILE_H_ #define MSP_IO_FILE_H_ +#include #include -#include "base.h" #include "buffered.h" #include "filtered.h" -#include "seek.h" +#include "handle.h" +#include "seekable.h" namespace Msp { namespace IO { +class file_not_found: public std::runtime_error +{ +public: + file_not_found(const std::string &fn): std::runtime_error(fn) { } +}; + + /** A class for reading and writing files. Non-blocking mode is not supported on Win32. */ -class File: public Base +class File: public Seekable { public: enum CreateMode @@ -35,10 +43,6 @@ public: File(const std::string &, Mode = M_READ, CreateMode = CreateMode(C_CREATE+C_TRUNCATE)); virtual ~File(); - /** Closes the file. Any attempt to access the file after this will cause - an exception to be thrown. */ - void close(); - void set_block(bool); protected: @@ -48,16 +52,10 @@ protected: public: virtual void sync(); - /** Changes the read/write offset of the file. Returns the new offset. */ - virtual int seek(int, SeekType); - - /** Returns the current read/write offset of the file. */ - virtual int tell() const; + virtual SeekOffset seek(SeekOffset, SeekType); + virtual SeekOffset tell() const; - virtual Handle get_event_handle() { return handle; } - -private: - void check_access(Mode) const; + virtual const Handle &get_handle(Mode); }; inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)