Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

file.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00029 #ifndef header_file
00030 #define header_file
00031 
00032 #include "iodevice.h"
00033 #include "bytearray.h"
00034 
00035 class CL_SecurityDescriptor;
00036 
00037 class CL_File : public CL_IODevice
00038 {
00040 public:
00041         enum AccessFlags
00042         {
00043                 access_read  = 1,
00044                 access_write = 2
00045         };
00046         
00047         enum ShareFlags
00048         {
00049                 share_read   = 1,
00050                 share_write  = 2,
00051                 share_delete = 4,
00052                 share_all    = share_read + share_write + share_delete
00053         };
00054         
00055         enum OpenMode
00056         {
00057                 open_always,
00058                 open_existing,
00059                 open_existing_truncate
00060         };
00061         
00062         enum CreateMode
00063         {
00064                 create_always,
00065                 create_new
00066         };
00067 
00069 public:
00070         CL_File();
00071         
00072         CL_File(
00073                 const CL_String &filename,
00074                 CreateMode mode,
00075                 unsigned int access = access_read | access_write,
00076                 unsigned int share = share_all);
00077 
00078         CL_File(
00079                 const CL_String &filename,
00080                 CreateMode mode,
00081                 const CL_SecurityDescriptor &permissions,
00082                 unsigned int access = access_read | access_write,
00083                 unsigned int share = share_all);
00084 
00085         CL_File(
00086                 const CL_String &filename,
00087                 OpenMode mode = open_existing,
00088                 unsigned int access = access_read | access_write,
00089                 unsigned int share = share_all);
00090 
00091         CL_File(
00092                 const CL_String &filename,
00093                 OpenMode mode,
00094                 const CL_SecurityDescriptor &permissions,
00095                 unsigned int access = access_read | access_write,
00096                 unsigned int share = share_all);
00097 
00098         ~CL_File();
00099 
00101 public:
00102         int get_size() const;
00103         
00104         int get_position() const;
00105         
00106         CL_SecurityDescriptor get_permissions() const;
00107 
00109 public:
00110         bool create(
00111                 const CL_String &filename,
00112                 CreateMode mode = create_always,
00113                 unsigned int access = access_read | access_write,
00114                 unsigned int share = share_all);
00115 
00116         bool create(
00117                 const CL_String &filename,
00118                 CreateMode mode,
00119                 const CL_SecurityDescriptor &permissions,
00120                 unsigned int access = access_read | access_write,
00121                 unsigned int share = share_all);
00122 
00123         bool open(
00124                 const CL_String &filename,
00125                 OpenMode mode = open_existing,
00126                 unsigned int access = access_read | access_write,
00127                 unsigned int share = share_all);
00128 
00129         bool open(
00130                 const CL_String &filename,
00131                 OpenMode mode,
00132                 const CL_SecurityDescriptor &permissions,
00133                 unsigned int access = access_read | access_write,
00134                 unsigned int share = share_all);
00135         
00136         void close();
00137         
00138         bool set_permissions(const CL_SecurityDescriptor &permissions);
00139         
00140         int read(void *buffer, int size, bool read_all = true);
00141 
00142         int write(const void *buffer, int size, bool write_all = true);
00143 
00144         int send(const void *data, int len, bool send_all = true);
00145 
00146         int receive(void *data, int len, bool receive_all = true);
00147 
00148         int peek(void *data, int len);
00149 
00150         bool seek(int position, SeekMode mode = seek_set);
00151 
00153 private:
00154         int lowlevel_read(void *buffer, int size, bool read_all);
00155 
00156 #ifdef WIN32
00157         HANDLE handle;
00158 #else
00159         int handle;
00160 #endif
00161         CL_ByteArray peeked_data;
00162 };
00163 
00164 #endif

Generated on Sat Feb 19 22:51:16 2005 for npcore by  doxygen 1.4.1