ClanLib  2.3.7
file.h
Go to the documentation of this file.
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2011 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
31 
32 #pragma once
33 
34 #include "../api_core.h"
35 #include "iodevice.h"
36 #include "../System/databuffer.h"
37 
39 
44 {
47 public:
49  static CL_String read_text(const CL_String &filename);
50 
52  static CL_DataBuffer read_bytes(const CL_String &filename);
54 
57 public:
59 
61  {
63  access_read = 1,
64 
66  access_write = 2,
67 
69  access_read_write = access_read | access_write
70  };
71 
74  {
76  share_read = 1,
77 
79  share_write = 2,
80 
82  share_delete = 4,
83 
85  share_all = share_read + share_write + share_delete
86  };
87 
89  enum OpenMode
90  {
93 
96 
99 
102 
104  create_new
105  };
106 
108  enum Flags
109  {
110  flag_write_through = 1,
111  flag_no_buffering = 2,
112  flag_random_access = 4,
113  flag_sequential_scan = 8
114  };
115 
119 
120 public:
122  CL_File();
123 
127  CL_File(
128  const CL_String &filename);
129 
133  CL_File(
134  const CL_String &filename,
135  OpenMode mode,
136  unsigned int access,
137  unsigned int share = share_all,
138  unsigned int flags = 0);
139 
143  CL_File(
144  const CL_String &filename,
145  OpenMode mode,
146  const CL_SecurityDescriptor &permissions,
147  unsigned int access,
148  unsigned int share = share_all,
149  unsigned int flags = 0);
150 
151  ~CL_File();
152 
156 
157 public:
159  CL_SecurityDescriptor get_permissions() const;
160 
164 
165 public:
169  bool open(
170  const CL_String &filename);
171 
175  bool open(
176  const CL_String &filename,
177  OpenMode mode,
178  unsigned int access,
179  unsigned int share = share_all,
180  unsigned int flags = 0);
181 
185  bool open(
186  const CL_String &filename,
187  OpenMode mode,
188  const CL_SecurityDescriptor &permissions,
189  unsigned int access,
190  unsigned int share = share_all,
191  unsigned int flags = 0);
192 
194  void close();
195 
197  bool set_permissions(const CL_SecurityDescriptor &permissions);
198 
202 
203 private:
205 };
206