]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/file.h
Move most platform-specific code into overlay directories
[libs/core.git] / source / io / file.h
index 57dc6831449416a0a0e9af75626ac1702757c8ce..d106561e5f599cc31367be5f3de9140a4d349cbf 100644 (file)
@@ -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,13 +51,12 @@ 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);
+private:
+       void platform_init(const std::string &, CreateMode);
+public:
        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:
@@ -56,13 +66,10 @@ protected:
 public:
        virtual void sync();
 
-       virtual unsigned seek(int, SeekType);
-       virtual unsigned tell() const;
+       virtual SeekOffset seek(SeekOffset, SeekType);
+       virtual SeekOffset tell() const;
 
-       virtual const 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)