]> git.tdb.fi Git - libs/core.git/blobdiff - source/file.h
Move class members and comments around
[libs/core.git] / source / file.h
index 4e86e29642c47dd35b52b0978b6b7be7b38d05f8..05aaf9565a08653f278773e010fee4acb6361779 100644 (file)
@@ -1,9 +1,3 @@
-/* $Id$
-
-This file is part of libmspio
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
 #ifndef MSP_IO_FILE_H_
 #define MSP_IO_FILE_H_
 
@@ -26,32 +20,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));
+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)