file.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 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 may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_core.h"
00035 #include "iodevice.h"
00036 #include "../System/databuffer.h"
00037 
00038 class CL_SecurityDescriptor;
00039 
00043 class CL_API_CORE CL_File : public CL_IODevice
00044 {
00047 public:
00049         static CL_String read_text(const CL_String &filename);
00050 
00052         static CL_DataBuffer read_bytes(const CL_String &filename);
00054 
00057 public:
00059 
00060         enum AccessFlags
00061         {
00063                 access_read  = 1,
00064 
00066                 access_write = 2,
00067 
00069                 access_read_write = access_read | access_write
00070         };
00071 
00073         enum ShareFlags
00074         {
00076                 share_read   = 1,
00077 
00079                 share_write  = 2,
00080 
00082                 share_delete = 4,
00083 
00085                 share_all    = share_read + share_write + share_delete
00086         };
00087 
00089         enum OpenMode
00090         {
00092                 open_always,
00093 
00095                 open_existing,
00096 
00098                 open_existing_truncate,
00099 
00101                 create_always,
00102 
00104                 create_new
00105         };
00106 
00108         enum Flags
00109         {
00110                 flag_write_through   = 1,
00111                 flag_no_buffering    = 2,
00112                 flag_random_access   = 4,
00113                 flag_sequential_scan = 8
00114         };
00115 
00119 
00120 public:
00122         CL_File();
00123 
00127         CL_File(
00128                 const CL_String &filename);
00129 
00133         CL_File(
00134                 const CL_String &filename,
00135                 OpenMode mode,
00136                 unsigned int access,
00137                 unsigned int share = share_all,
00138                 unsigned int flags = 0);
00139 
00143         CL_File(
00144                 const CL_String &filename,
00145                 OpenMode mode,
00146                 const CL_SecurityDescriptor &permissions,
00147                 unsigned int access,
00148                 unsigned int share = share_all,
00149                 unsigned int flags = 0);
00150 
00151         ~CL_File();
00152 
00156 
00157 public:
00159         CL_SecurityDescriptor get_permissions() const;
00160 
00164 
00165 public:
00169         bool open(
00170                 const CL_String &filename);
00171 
00175         bool open(
00176                 const CL_String &filename,
00177                 OpenMode mode,
00178                 unsigned int access,
00179                 unsigned int share = share_all,
00180                 unsigned int flags = 0);
00181 
00185         bool open(
00186                 const CL_String &filename,
00187                 OpenMode mode,
00188                 const CL_SecurityDescriptor &permissions,
00189                 unsigned int access,
00190                 unsigned int share = share_all,
00191                 unsigned int flags = 0);
00192 
00194         void close();
00195 
00197         bool set_permissions(const CL_SecurityDescriptor &permissions);
00198 
00202 
00203 private:
00205 };
00206