Merge remote-tracking branch 'gvdb/master'
[platform/upstream/glib.git] / docs / reference / glib / tmpl / fileutils.sgml
1 <!-- ##### SECTION Title ##### -->
2 File Utilities
3
4 <!-- ##### SECTION Short_Description ##### -->
5 various file-related functions
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 There is a group of functions which wrap the common POSIX functions 
10 dealing with filenames (g_open(), g_rename(), g_mkdir(), g_stat(), 
11 g_unlink(), g_remove(), g_fopen(), g_freopen()). The point of these 
12 wrappers is to make it possible to handle file names with any Unicode 
13 characters in them on Windows without having to use ifdefs and the 
14 wide character API in the application code.
15 </para>
16 <para>
17 The pathname argument should be in the GLib file name encoding. On
18 POSIX this is the actual on-disk encoding which might correspond to
19 the locale settings of the process (or the 
20 <envar>G_FILENAME_ENCODING</envar> environment variable), or not.
21 </para>
22 <para>
23 On Windows the GLib file name encoding is UTF-8. Note that the
24 Microsoft C library does not use UTF-8, but has separate APIs for
25 current system code page and wide characters (UTF-16). The GLib
26 wrappers call the wide character API if present (on modern Windows
27 systems), otherwise convert to/from the system code page.
28 </para>
29
30 <para>
31 Another group of functions allows to open and read directories
32 in the GLib file name encoding. These are g_dir_open(), 
33 g_dir_read_name(), g_dir_rewind(), g_dir_close().
34 </para>
35
36 <!-- ##### SECTION See_Also ##### -->
37 <para>
38
39 </para>
40
41 <!-- ##### SECTION Stability_Level ##### -->
42
43
44 <!-- ##### SECTION Image ##### -->
45
46
47 <!-- ##### ENUM GFileError ##### -->
48 <para>
49 Values corresponding to <literal>errno</literal> codes returned from file operations
50 on UNIX. Unlike <literal>errno</literal> codes, #GFileError values are available on 
51 all systems, even Windows. The exact meaning of each code depends on what
52 sort of file operation you were performing; the UNIX documentation
53 gives more details. The following error code descriptions come 
54 from the GNU C Library manual, and are under the copyright
55 of that manual.
56 </para>
57
58 <para>
59 It's not very portable to make detailed assumptions about exactly
60 which errors will be returned from a given operation. Some errors
61 don't occur on some systems, etc., sometimes there are subtle
62 differences in when a system will report a given error, etc.
63 </para>
64
65 @G_FILE_ERROR_EXIST: Operation not permitted; only the owner of the
66      file (or other resource) or processes with special privileges can
67      perform the operation.
68 @G_FILE_ERROR_ISDIR: File is a directory; you cannot open a directory
69      for writing, or create or remove hard links to it.
70 @G_FILE_ERROR_ACCES: Permission denied; the file permissions do not
71      allow the attempted operation.
72 @G_FILE_ERROR_NAMETOOLONG: Filename too long.
73 @G_FILE_ERROR_NOENT: No such file or directory.  This is a "file
74      doesn't exist" error for ordinary files that are referenced in
75      contexts where they are expected to already exist.
76 @G_FILE_ERROR_NOTDIR: A file that isn't a directory was specified when
77      a directory is required.
78 @G_FILE_ERROR_NXIO: No such device or address.  The system tried to
79      use the device represented by a file you specified, and it
80      couldn't find the device.  This can mean that the device file was
81      installed incorrectly, or that the physical device is missing or
82      not correctly attached to the computer.
83 @G_FILE_ERROR_NODEV: This file is of a type that doesn't support
84      mapping.
85 @G_FILE_ERROR_ROFS: The directory containing the new link can't be
86           modified because it's on a read-only file system.
87 @G_FILE_ERROR_TXTBSY: Text file busy.
88 @G_FILE_ERROR_FAULT: You passed in a pointer to bad memory.
89   (GLib won't reliably return this, don't pass in pointers to bad
90   memory.)
91 @G_FILE_ERROR_LOOP: Too many levels of symbolic links were encountered
92   in looking up a file name.  This often indicates a cycle of symbolic
93   links.
94 @G_FILE_ERROR_NOSPC: No space left on device; write operation on a
95   file failed because the disk is full.
96 @G_FILE_ERROR_NOMEM: No memory available.  The system cannot allocate
97      more virtual memory because its capacity is full.
98 @G_FILE_ERROR_MFILE: The current process has too many files open and
99      can't open any more.  Duplicate descriptors do count toward this
100      limit.
101 @G_FILE_ERROR_NFILE: There are too many distinct file openings in the
102      entire system.
103 @G_FILE_ERROR_BADF: Bad file descriptor; for example, I/O on a
104      descriptor that has been closed or reading from a descriptor open
105      only for writing (or vice versa).
106 @G_FILE_ERROR_INVAL: Invalid argument.  This is used to indicate
107      various kinds of problems with passing the wrong argument to a
108      library function.
109 @G_FILE_ERROR_PIPE: Broken pipe; there is no process reading from the
110      other end of a pipe.  Every library function that returns this
111      error code also generates a `SIGPIPE' signal; this signal
112      terminates the program if not handled or blocked.  Thus, your
113      program will never actually see this code unless it has handled or
114      blocked `SIGPIPE'.
115 @G_FILE_ERROR_AGAIN: Resource temporarily unavailable; the call might
116      work if you try again later.
117 @G_FILE_ERROR_INTR: Interrupted function call; an asynchronous signal
118      occurred and prevented completion of the call.  When this
119      happens, you should try the call again.
120 @G_FILE_ERROR_IO: Input/output error; usually used for physical read
121     or write errors. i.e. the disk or other physical device hardware
122     is returning errors.
123 @G_FILE_ERROR_PERM: Operation not permitted; only the owner of the
124      file (or other resource) or processes with special privileges can
125      perform the operation.
126 @G_FILE_ERROR_NOSYS: Function not implemented; this indicates that the
127     system is missing some functionality.
128 @G_FILE_ERROR_FAILED: Does not correspond to a UNIX error code; this
129   is the standard "failed for unspecified reason" error code present in 
130   all #GError error code enumerations. Returned if no specific
131   code applies.
132
133 <!-- ##### MACRO G_FILE_ERROR ##### -->
134 <para>
135 Error domain for file operations. Errors in this domain will
136 be from the #GFileError enumeration. See #GError for information on 
137 error domains.
138 </para>
139
140
141
142 <!-- ##### ENUM GFileTest ##### -->
143 <para>
144 A test to perform on a file using g_file_test().
145 </para>
146
147 @G_FILE_TEST_IS_REGULAR: %TRUE if the file is a regular file (not a directory).
148     Note that this test will also return %TRUE if the tested file is a symlink
149     to a regular file.
150 @G_FILE_TEST_IS_SYMLINK: %TRUE if the file is a symlink.
151 @G_FILE_TEST_IS_DIR: %TRUE if the file is a directory.
152 @G_FILE_TEST_IS_EXECUTABLE: %TRUE if the file is executable.
153 @G_FILE_TEST_EXISTS: %TRUE if the file exists. 
154     It may or may not be a regular file.
155
156 <!-- ##### FUNCTION g_file_error_from_errno ##### -->
157 <para>
158
159 </para>
160
161 @err_no: 
162 @Returns: 
163
164
165 <!-- ##### FUNCTION g_file_get_contents ##### -->
166 <para>
167
168 </para>
169
170 @filename: 
171 @contents: 
172 @length: 
173 @error: 
174 @Returns: 
175
176
177 <!-- ##### FUNCTION g_file_set_contents ##### -->
178 <para>
179
180 </para>
181
182 @filename: 
183 @contents: 
184 @length: 
185 @error: 
186 @Returns: 
187
188
189 <!-- ##### FUNCTION g_file_test ##### -->
190 <para>
191
192 </para>
193
194 @filename: 
195 @test: 
196 @Returns: 
197
198
199 <!-- ##### FUNCTION g_mkstemp ##### -->
200 <para>
201
202 </para>
203
204 @tmpl: 
205 @Returns: 
206
207
208 <!-- ##### FUNCTION g_mkstemp_full ##### -->
209 <para>
210
211 </para>
212
213 @tmpl: 
214 @flags: 
215 @mode: 
216 @Returns: 
217
218
219 <!-- ##### FUNCTION g_file_open_tmp ##### -->
220 <para>
221
222 </para>
223
224 @tmpl: 
225 @name_used: 
226 @error: 
227 @Returns: 
228
229
230 <!-- ##### FUNCTION g_file_read_link ##### -->
231 <para>
232
233 </para>
234
235 @filename: 
236 @error: 
237 @Returns: 
238
239
240 <!-- ##### FUNCTION g_mkdir_with_parents ##### -->
241 <para>
242
243 </para>
244
245 @pathname: 
246 @mode: 
247 @Returns: 
248
249
250 <!-- ##### FUNCTION g_mkdtemp ##### -->
251 <para>
252
253 </para>
254
255 @tmpl: 
256 @Returns: 
257
258
259 <!-- ##### FUNCTION g_mkdtemp_full ##### -->
260 <para>
261
262 </para>
263
264 @tmpl: 
265 @mode: 
266 @Returns: 
267
268
269 <!-- ##### FUNCTION g_dir_make_tmp ##### -->
270 <para>
271
272 </para>
273
274 @tmpl: 
275 @error: 
276 @Returns: 
277
278
279 <!-- ##### STRUCT GDir ##### -->
280 <para>
281 An opaque structure representing an opened directory.
282 </para>
283
284
285 <!-- ##### FUNCTION g_dir_open ##### -->
286 <para>
287
288 </para>
289
290 @path: 
291 @flags: 
292 @error: 
293 @Returns: 
294
295
296 <!-- ##### FUNCTION g_dir_read_name ##### -->
297 <para>
298
299 </para>
300
301 @dir: 
302 @Returns: 
303
304
305 <!-- ##### FUNCTION g_dir_rewind ##### -->
306 <para>
307
308 </para>
309
310 @dir: 
311
312
313 <!-- ##### FUNCTION g_dir_close ##### -->
314 <para>
315
316 </para>
317
318 @dir: 
319
320
321 <!-- ##### STRUCT GMappedFile ##### -->
322 <para>
323 The #GMappedFile represents a file mapping created with
324 g_mapped_file_new(). It has only private members and should
325 not be accessed directly.
326 </para>
327
328
329 <!-- ##### FUNCTION g_mapped_file_new ##### -->
330 <para>
331
332 </para>
333
334 @filename: 
335 @writable: 
336 @error: 
337 @Returns: 
338
339
340 <!-- ##### FUNCTION g_mapped_file_ref ##### -->
341 <para>
342
343 </para>
344
345 @file: 
346 @Returns: 
347
348
349 <!-- ##### FUNCTION g_mapped_file_unref ##### -->
350 <para>
351
352 </para>
353
354 @file: 
355
356
357 <!-- ##### FUNCTION g_mapped_file_free ##### -->
358 <para>
359
360 </para>
361
362 @file: 
363
364
365 <!-- ##### FUNCTION g_mapped_file_get_length ##### -->
366 <para>
367
368 </para>
369
370 @file: 
371 @Returns: 
372
373
374 <!-- ##### FUNCTION g_mapped_file_get_contents ##### -->
375 <para>
376
377 </para>
378
379 @file: 
380 @Returns: 
381
382
383 <!-- ##### FUNCTION g_open ##### -->
384 <para>
385
386 </para>
387
388 @filename: 
389 @flags: 
390 @mode: 
391 @Returns: 
392
393
394 <!-- ##### FUNCTION g_rename ##### -->
395 <para>
396
397 </para>
398
399 @oldfilename: 
400 @newfilename: 
401 @Returns: 
402
403
404 <!-- ##### FUNCTION g_mkdir ##### -->
405 <para>
406
407 </para>
408
409 @filename: 
410 @mode: 
411 @Returns: 
412
413
414 <!-- ##### TYPEDEF GStatBuf ##### -->
415 <para>
416
417 </para>
418
419
420 <!-- ##### FUNCTION g_stat ##### -->
421 <para>
422
423 </para>
424
425 @filename: 
426 @buf: 
427 @Returns: 
428
429
430 <!-- ##### FUNCTION g_lstat ##### -->
431 <para>
432
433 </para>
434
435 @filename: 
436 @buf: 
437 @Returns: 
438
439
440 <!-- ##### FUNCTION g_unlink ##### -->
441 <para>
442
443 </para>
444
445 @filename: 
446 @Returns: 
447
448
449 <!-- ##### FUNCTION g_remove ##### -->
450 <para>
451
452 </para>
453
454 @filename: 
455 @Returns: 
456
457
458 <!-- ##### FUNCTION g_rmdir ##### -->
459 <para>
460
461 </para>
462
463 @filename: 
464 @Returns: 
465
466
467 <!-- ##### FUNCTION g_fopen ##### -->
468 <para>
469
470 </para>
471
472 @filename: 
473 @mode: 
474 @Returns: 
475
476
477 <!-- ##### FUNCTION g_freopen ##### -->
478 <para>
479
480 </para>
481
482 @filename: 
483 @mode: 
484 @stream: 
485 @Returns: 
486
487
488 <!-- ##### FUNCTION g_chmod ##### -->
489 <para>
490
491 </para>
492
493 @filename: 
494 @mode: 
495 @Returns: 
496
497
498 <!-- ##### FUNCTION g_access ##### -->
499 <para>
500
501 </para>
502
503 @filename: 
504 @mode: 
505 @Returns: 
506
507
508 <!-- ##### FUNCTION g_creat ##### -->
509 <para>
510
511 </para>
512
513 @filename: 
514 @mode: 
515 @Returns: 
516
517
518 <!-- ##### FUNCTION g_chdir ##### -->
519 <para>
520
521 </para>
522
523 @path: 
524 @Returns: 
525
526
527 <!-- ##### FUNCTION g_utime ##### -->
528 <para>
529
530 </para>
531
532 @filename: 
533 @utb: 
534 @Returns: 
535
536