X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fio%2Ffile.h;h=90a1041ccda6520db5386b724f43fe6e936bfe85;hp=6c7169718872a4fb5b8128723fd5ebcb28ba711c;hb=933356a36607f5d4480172e285071d4d7dfc5a7b;hpb=d16185720fa344263367dbd50c61bfc8183d99a4 diff --git a/source/io/file.h b/source/io/file.h index 6c71697..90a1041 100644 --- a/source/io/file.h +++ b/source/io/file.h @@ -15,6 +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() { } }; @@ -30,7 +38,10 @@ public: { C_NONE = 0, C_CREATE = 1, - C_TRUNCATE = 2 + C_TRUNCATE = 2, + C_OVERWRITE = C_CREATE+C_TRUNCATE, + C_EXCLUSIVE = 4, + C_NEW = C_CREATE+C_EXCLUSIVE }; private: @@ -40,7 +51,7 @@ 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)); + File(const std::string &, Mode = M_READ, CreateMode = C_OVERWRITE); virtual ~File(); void set_block(bool); @@ -54,6 +65,8 @@ public: virtual SeekOffset seek(SeekOffset, SeekType); virtual SeekOffset tell() const; + + virtual const Handle &get_handle(Mode); }; inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)