X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffile.h;fp=source%2Ffile.h;h=05aaf9565a08653f278773e010fee4acb6361779;hp=6353a4626c5461036ffd4a935d15b12b0efbffbc;hb=b97d4e9f86e90254ab9edef7ee62a910f6333c78;hpb=49c1f3c3ffdf318579a809f3f800442c0c76c818 diff --git a/source/file.h b/source/file.h index 6353a46..05aaf95 100644 --- a/source/file.h +++ b/source/file.h @@ -25,27 +25,39 @@ public: C_TRUNCATE = 2 }; - File(const std::string &, Mode = M_READ, CreateMode =CreateMode(C_CREATE+C_TRUNCATE)); +private: + Handle handle; + +public: + /** Creates a new file object and opens it. If the create flag is set and + 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 = 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: + virtual unsigned do_write(const char *, unsigned); + virtual unsigned do_read(char *, unsigned); + +public: virtual void sync(); - virtual int seek(int, SeekType); - virtual int tell() const; + /** 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 Handle get_event_handle() { return handle; } - virtual ~File(); private: - Handle handle; - - void check_access(Mode) const; -protected: - virtual unsigned do_write(const char *, unsigned); - virtual unsigned do_read(char *, unsigned); + void check_access(Mode) const; }; inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)