diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-12-09 15:38:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-12-09 15:38:55 +0000 |
commit | 101b56cdd67b56b4db3be7a50d9050d2a1743715 (patch) | |
tree | 65fa45ef0f625551c6e94c6271ce3e74a3b36563 /src/include/gnunet_disk_lib.h | |
parent | 36a48508667b24317d2c64cc261d6c03141111c4 (diff) | |
download | gnunet-101b56cdd67b56b4db3be7a50d9050d2a1743715.tar.gz gnunet-101b56cdd67b56b4db3be7a50d9050d2a1743715.zip |
adding GNUNET_DISK_file_backup function; fixing #2646
Diffstat (limited to 'src/include/gnunet_disk_lib.h')
-rw-r--r-- | src/include/gnunet_disk_lib.h | 171 |
1 files changed, 91 insertions, 80 deletions
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index 9d4cd1820..dd42f9e91 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2001-2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -17,10 +17,10 @@ | |||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file include/gnunet_disk_lib.h | 21 | * @file include/gnunet_disk_lib.h |
23 | * @brief disk IO apis | 22 | * @brief disk IO apis |
23 | * @author Christian Grothoff | ||
24 | */ | 24 | */ |
25 | #ifndef GNUNET_DISK_LIB_H | 25 | #ifndef GNUNET_DISK_LIB_H |
26 | #define GNUNET_DISK_LIB_H | 26 | #define GNUNET_DISK_LIB_H |
@@ -85,8 +85,7 @@ struct GNUNET_DISK_FileHandle | |||
85 | */ | 85 | */ |
86 | int fd; | 86 | int fd; |
87 | 87 | ||
88 | #endif /* | 88 | #endif |
89 | */ | ||
90 | }; | 89 | }; |
91 | 90 | ||
92 | 91 | ||
@@ -113,39 +112,39 @@ extern "C" | |||
113 | enum GNUNET_DISK_OpenFlags | 112 | enum GNUNET_DISK_OpenFlags |
114 | { | 113 | { |
115 | 114 | ||
116 | /** | 115 | /** |
117 | * Open the file for reading | 116 | * Open the file for reading |
118 | */ | 117 | */ |
119 | GNUNET_DISK_OPEN_READ = 1, | 118 | GNUNET_DISK_OPEN_READ = 1, |
120 | 119 | ||
121 | /** | 120 | /** |
122 | * Open the file for writing | 121 | * Open the file for writing |
123 | */ | 122 | */ |
124 | GNUNET_DISK_OPEN_WRITE = 2, | 123 | GNUNET_DISK_OPEN_WRITE = 2, |
125 | 124 | ||
126 | /** | 125 | /** |
127 | * Open the file for both reading and writing | 126 | * Open the file for both reading and writing |
128 | */ | 127 | */ |
129 | GNUNET_DISK_OPEN_READWRITE = 3, | 128 | GNUNET_DISK_OPEN_READWRITE = 3, |
130 | 129 | ||
131 | /** | 130 | /** |
132 | * Fail if file already exists | 131 | * Fail if file already exists |
133 | */ | 132 | */ |
134 | GNUNET_DISK_OPEN_FAILIFEXISTS = 4, | 133 | GNUNET_DISK_OPEN_FAILIFEXISTS = 4, |
135 | 134 | ||
136 | /** | 135 | /** |
137 | * Truncate file if it exists | 136 | * Truncate file if it exists |
138 | */ | 137 | */ |
139 | GNUNET_DISK_OPEN_TRUNCATE = 8, | 138 | GNUNET_DISK_OPEN_TRUNCATE = 8, |
140 | 139 | ||
141 | /** | 140 | /** |
142 | * Create file if it doesn't exist | 141 | * Create file if it doesn't exist |
143 | */ | 142 | */ |
144 | GNUNET_DISK_OPEN_CREATE = 16, | 143 | GNUNET_DISK_OPEN_CREATE = 16, |
145 | 144 | ||
146 | /** | 145 | /** |
147 | * Append to the file | 146 | * Append to the file |
148 | */ | 147 | */ |
149 | GNUNET_DISK_OPEN_APPEND = 32 | 148 | GNUNET_DISK_OPEN_APPEND = 32 |
150 | }; | 149 | }; |
151 | 150 | ||
@@ -154,18 +153,19 @@ enum GNUNET_DISK_OpenFlags | |||
154 | */ | 153 | */ |
155 | enum GNUNET_DISK_MapType | 154 | enum GNUNET_DISK_MapType |
156 | { | 155 | { |
157 | /** | 156 | /** |
158 | * Read-only memory map. | 157 | * Read-only memory map. |
159 | */ | 158 | */ |
160 | GNUNET_DISK_MAP_TYPE_READ = 1, | 159 | GNUNET_DISK_MAP_TYPE_READ = 1, |
161 | 160 | ||
162 | /** | 161 | /** |
163 | * Write-able memory map. | 162 | * Write-able memory map. |
164 | */ | 163 | */ |
165 | GNUNET_DISK_MAP_TYPE_WRITE = 2, | 164 | GNUNET_DISK_MAP_TYPE_WRITE = 2, |
166 | /** | 165 | |
167 | * Read-write memory map. | 166 | /** |
168 | */ | 167 | * Read-write memory map. |
168 | */ | ||
169 | GNUNET_DISK_MAP_TYPE_READWRITE = 3 | 169 | GNUNET_DISK_MAP_TYPE_READWRITE = 3 |
170 | }; | 170 | }; |
171 | 171 | ||
@@ -175,54 +175,54 @@ enum GNUNET_DISK_MapType | |||
175 | */ | 175 | */ |
176 | enum GNUNET_DISK_AccessPermissions | 176 | enum GNUNET_DISK_AccessPermissions |
177 | { | 177 | { |
178 | /** | 178 | /** |
179 | * Nobody is allowed to do anything to the file. | 179 | * Nobody is allowed to do anything to the file. |
180 | */ | 180 | */ |
181 | GNUNET_DISK_PERM_NONE = 0, | 181 | GNUNET_DISK_PERM_NONE = 0, |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * Owner can read. | 184 | * Owner can read. |
185 | */ | 185 | */ |
186 | GNUNET_DISK_PERM_USER_READ = 1, | 186 | GNUNET_DISK_PERM_USER_READ = 1, |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * Owner can write. | 189 | * Owner can write. |
190 | */ | 190 | */ |
191 | GNUNET_DISK_PERM_USER_WRITE = 2, | 191 | GNUNET_DISK_PERM_USER_WRITE = 2, |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Owner can execute. | 194 | * Owner can execute. |
195 | */ | 195 | */ |
196 | GNUNET_DISK_PERM_USER_EXEC = 4, | 196 | GNUNET_DISK_PERM_USER_EXEC = 4, |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Group can read. | 199 | * Group can read. |
200 | */ | 200 | */ |
201 | GNUNET_DISK_PERM_GROUP_READ = 8, | 201 | GNUNET_DISK_PERM_GROUP_READ = 8, |
202 | 202 | ||
203 | /** | 203 | /** |
204 | * Group can write. | 204 | * Group can write. |
205 | */ | 205 | */ |
206 | GNUNET_DISK_PERM_GROUP_WRITE = 16, | 206 | GNUNET_DISK_PERM_GROUP_WRITE = 16, |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Group can execute. | 209 | * Group can execute. |
210 | */ | 210 | */ |
211 | GNUNET_DISK_PERM_GROUP_EXEC = 32, | 211 | GNUNET_DISK_PERM_GROUP_EXEC = 32, |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Everybody can read. | 214 | * Everybody can read. |
215 | */ | 215 | */ |
216 | GNUNET_DISK_PERM_OTHER_READ = 64, | 216 | GNUNET_DISK_PERM_OTHER_READ = 64, |
217 | 217 | ||
218 | /** | 218 | /** |
219 | * Everybody can write. | 219 | * Everybody can write. |
220 | */ | 220 | */ |
221 | GNUNET_DISK_PERM_OTHER_WRITE = 128, | 221 | GNUNET_DISK_PERM_OTHER_WRITE = 128, |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * Everybody can execute. | 224 | * Everybody can execute. |
225 | */ | 225 | */ |
226 | GNUNET_DISK_PERM_OTHER_EXEC = 256 | 226 | GNUNET_DISK_PERM_OTHER_EXEC = 256 |
227 | }; | 227 | }; |
228 | 228 | ||
@@ -233,19 +233,19 @@ enum GNUNET_DISK_AccessPermissions | |||
233 | */ | 233 | */ |
234 | enum GNUNET_DISK_Seek | 234 | enum GNUNET_DISK_Seek |
235 | { | 235 | { |
236 | /** | 236 | /** |
237 | * Seek an absolute position (from the start of the file). | 237 | * Seek an absolute position (from the start of the file). |
238 | */ | 238 | */ |
239 | GNUNET_DISK_SEEK_SET = 0, | 239 | GNUNET_DISK_SEEK_SET = 0, |
240 | 240 | ||
241 | /** | 241 | /** |
242 | * Seek a relative position (from the current offset). | 242 | * Seek a relative position (from the current offset). |
243 | */ | 243 | */ |
244 | GNUNET_DISK_SEEK_CUR = 1, | 244 | GNUNET_DISK_SEEK_CUR = 1, |
245 | 245 | ||
246 | /** | 246 | /** |
247 | * Seek an absolute position from the end of the file. | 247 | * Seek an absolute position from the end of the file. |
248 | */ | 248 | */ |
249 | GNUNET_DISK_SEEK_END = 2 | 249 | GNUNET_DISK_SEEK_END = 2 |
250 | }; | 250 | }; |
251 | 251 | ||
@@ -255,14 +255,14 @@ enum GNUNET_DISK_Seek | |||
255 | */ | 255 | */ |
256 | enum GNUNET_DISK_PipeEnd | 256 | enum GNUNET_DISK_PipeEnd |
257 | { | 257 | { |
258 | /** | 258 | /** |
259 | * The reading-end of a pipe. | 259 | * The reading-end of a pipe. |
260 | */ | 260 | */ |
261 | GNUNET_DISK_PIPE_END_READ = 0, | 261 | GNUNET_DISK_PIPE_END_READ = 0, |
262 | 262 | ||
263 | /** | 263 | /** |
264 | * The writing-end of a pipe. | 264 | * The writing-end of a pipe. |
265 | */ | 265 | */ |
266 | GNUNET_DISK_PIPE_END_WRITE = 1 | 266 | GNUNET_DISK_PIPE_END_WRITE = 1 |
267 | }; | 267 | }; |
268 | 268 | ||
@@ -301,6 +301,17 @@ GNUNET_DISK_file_test (const char *fil); | |||
301 | 301 | ||
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Move a file out of the way (create a backup) by | ||
305 | * renaming it to "orig.NUM~" where NUM is the smallest | ||
306 | * number that is not used yet. | ||
307 | * | ||
308 | * @param fil name of the file to back up | ||
309 | */ | ||
310 | void | ||
311 | GNUNET_DISK_file_backup (const char *fil); | ||
312 | |||
313 | |||
314 | /** | ||
304 | * Move the read/write pointer in a file | 315 | * Move the read/write pointer in a file |
305 | * @param h handle of an open file | 316 | * @param h handle of an open file |
306 | * @param offset position to move to | 317 | * @param offset position to move to |