36
37
<th width="100%" align="center">GLib Reference Manual</th>
37
38
<td><a accesskey="n" href="glib-URI-Functions.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
39
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3163988" class="shortcut">Top</a>
41
<a href="#id2864430" class="shortcut">Description</a></nobr></td></tr>
40
<tr><td colspan="5" class="shortcuts">
41
<a href="#glib-File-Utilities.synopsis" class="shortcut">Top</a>
43
<a href="#glib-File-Utilities.description" class="shortcut">Description</a>
43
46
<div class="refentry" lang="en">
44
47
<a name="glib-File-Utilities"></a><div class="titlepage"></div>
45
48
<div class="refnamediv"><table width="100%"><tr>
48
<a name="id3163988"></a><span class="refentrytitle">File Utilities</span>
50
<p>File Utilities — various file-related functions</p>
50
<h2><span class="refentrytitle"><a name="glib-File-Utilities.top_of_page"></a>File Utilities</span></h2>
51
<p>File Utilities — various file-related functions</p>
52
53
<td valign="top" align="right"></td>
53
54
</tr></table></div>
54
55
<div class="refsynopsisdiv">
56
<a name="glib-File-Utilities.synopsis"></a><h2>Synopsis</h2>
56
57
<pre class="synopsis">
58
59
#include <glib.h>
59
60
#include <glib/gstdio.h>
62
enum <a class="link" href="glib-File-Utilities.html#GFileError">GFileError</a>;
63
#define <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR:CAPS">G_FILE_ERROR</a>
64
enum <a class="link" href="glib-File-Utilities.html#GFileTest">GFileTest</a>;
65
<a class="link" href="glib-File-Utilities.html#GFileError">GFileError</a> <a class="link" href="glib-File-Utilities.html#g-file-error-from-errno">g_file_error_from_errno</a> (<a class="link" href="glib-Basic-Types.html#gint">gint</a> err_no);
66
<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="glib-File-Utilities.html#g-file-get-contents">g_file_get_contents</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
67
<a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **contents,
68
<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> *length,
69
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);
70
<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="glib-File-Utilities.html#g-file-set-contents">g_file_set_contents</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
71
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *contents,
72
<a class="link" href="glib-Basic-Types.html#gssize">gssize</a> length,
73
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);
74
<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> <a class="link" href="glib-File-Utilities.html#g-file-test">g_file_test</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
75
<a class="link" href="glib-File-Utilities.html#GFileTest">GFileTest</a> test);
76
<a class="link" href="glib-Basic-Types.html#gint">gint</a> <a class="link" href="glib-File-Utilities.html#g-mkstemp">g_mkstemp</a> (<a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *tmpl);
77
<a class="link" href="glib-Basic-Types.html#gint">gint</a> <a class="link" href="glib-File-Utilities.html#g-file-open-tmp">g_file_open_tmp</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *tmpl,
78
<a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **name_used,
79
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);
80
<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="glib-File-Utilities.html#g-file-read-link">g_file_read_link</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
81
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);
82
int <a class="link" href="glib-File-Utilities.html#g-mkdir-with-parents">g_mkdir_with_parents</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *pathname,
62
enum <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError">GFileError</a>;
63
#define <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR--CAPS" title="G_FILE_ERROR">G_FILE_ERROR</a>
64
enum <a class="link" href="glib-File-Utilities.html#GFileTest" title="enum GFileTest">GFileTest</a>;
65
<a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError">GFileError</a> <a class="link" href="glib-File-Utilities.html#g-file-error-from-errno" title="g_file_error_from_errno ()">g_file_error_from_errno</a> (<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> err_no);
66
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-File-Utilities.html#g-file-get-contents" title="g_file_get_contents ()">g_file_get_contents</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
67
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **contents,
68
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> *length,
69
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
70
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-File-Utilities.html#g-file-set-contents" title="g_file_set_contents ()">g_file_set_contents</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
71
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *contents,
72
<a class="link" href="glib-Basic-Types.html#gssize" title="gssize">gssize</a> length,
73
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
74
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> <a class="link" href="glib-File-Utilities.html#g-file-test" title="g_file_test ()">g_file_test</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
75
<a class="link" href="glib-File-Utilities.html#GFileTest" title="enum GFileTest">GFileTest</a> test);
76
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> <a class="link" href="glib-File-Utilities.html#g-mkstemp" title="g_mkstemp ()">g_mkstemp</a> (<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *tmpl);
77
<a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> <a class="link" href="glib-File-Utilities.html#g-file-open-tmp" title="g_file_open_tmp ()">g_file_open_tmp</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *tmpl,
78
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **name_used,
79
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
80
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> * <a class="link" href="glib-File-Utilities.html#g-file-read-link" title="g_file_read_link ()">g_file_read_link</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
81
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
82
int <a class="link" href="glib-File-Utilities.html#g-mkdir-with-parents" title="g_mkdir_with_parents ()">g_mkdir_with_parents</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *pathname,
85
<a class="link" href="glib-File-Utilities.html#GDir">GDir</a>;
86
<a class="link" href="glib-File-Utilities.html#GDir">GDir</a>* <a class="link" href="glib-File-Utilities.html#g-dir-open">g_dir_open</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *path,
87
<a class="link" href="glib-Basic-Types.html#guint">guint</a> flags,
88
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);
89
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="glib-File-Utilities.html#g-dir-read-name">g_dir_read_name</a> (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);
90
void <a class="link" href="glib-File-Utilities.html#g-dir-rewind">g_dir_rewind</a> (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);
91
void <a class="link" href="glib-File-Utilities.html#g-dir-close">g_dir_close</a> (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);
93
<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a>;
94
<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a>* <a class="link" href="glib-File-Utilities.html#g-mapped-file-new">g_mapped_file_new</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
95
<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> writable,
96
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);
97
void <a class="link" href="glib-File-Utilities.html#g-mapped-file-free">g_mapped_file_free</a> (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);
98
<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> <a class="link" href="glib-File-Utilities.html#g-mapped-file-get-length">g_mapped_file_get_length</a> (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);
99
<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* <a class="link" href="glib-File-Utilities.html#g-mapped-file-get-contents">g_mapped_file_get_contents</a> (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);
101
int <a class="link" href="glib-File-Utilities.html#g-open">g_open</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
85
<a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a>;
86
<a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a> * <a class="link" href="glib-File-Utilities.html#g-dir-open" title="g_dir_open ()">g_dir_open</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *path,
87
<a class="link" href="glib-Basic-Types.html#guint" title="guint">guint</a> flags,
88
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
89
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> * <a class="link" href="glib-File-Utilities.html#g-dir-read-name" title="g_dir_read_name ()">g_dir_read_name</a> (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a> *dir);
90
void <a class="link" href="glib-File-Utilities.html#g-dir-rewind" title="g_dir_rewind ()">g_dir_rewind</a> (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a> *dir);
91
void <a class="link" href="glib-File-Utilities.html#g-dir-close" title="g_dir_close ()">g_dir_close</a> (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a> *dir);
93
<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a>;
94
<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> * <a class="link" href="glib-File-Utilities.html#g-mapped-file-new" title="g_mapped_file_new ()">g_mapped_file_new</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
95
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> writable,
96
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);
97
void <a class="link" href="glib-File-Utilities.html#g-mapped-file-free" title="g_mapped_file_free ()">g_mapped_file_free</a> (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> *file);
98
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> <a class="link" href="glib-File-Utilities.html#g-mapped-file-get-length" title="g_mapped_file_get_length ()">g_mapped_file_get_length</a> (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> *file);
99
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> * <a class="link" href="glib-File-Utilities.html#g-mapped-file-get-contents" title="g_mapped_file_get_contents ()">g_mapped_file_get_contents</a> (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> *file);
101
int <a class="link" href="glib-File-Utilities.html#g-open" title="g_open ()">g_open</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
104
int <a class="link" href="glib-File-Utilities.html#g-rename">g_rename</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *oldfilename,
105
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *newfilename);
106
int <a class="link" href="glib-File-Utilities.html#g-mkdir">g_mkdir</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
104
int <a class="link" href="glib-File-Utilities.html#g-rename" title="g_rename ()">g_rename</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *oldfilename,
105
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *newfilename);
106
int <a class="link" href="glib-File-Utilities.html#g-mkdir" title="g_mkdir ()">g_mkdir</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
108
int <a class="link" href="glib-File-Utilities.html#g-stat">g_stat</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
110
int <a class="link" href="glib-File-Utilities.html#g-lstat">g_lstat</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
112
int <a class="link" href="glib-File-Utilities.html#g-unlink">g_unlink</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename);
113
int <a class="link" href="glib-File-Utilities.html#g-remove">g_remove</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename);
114
int <a class="link" href="glib-File-Utilities.html#g-rmdir">g_rmdir</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename);
115
FILE* <a class="link" href="glib-File-Utilities.html#g-fopen">g_fopen</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
116
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *mode);
117
FILE* <a class="link" href="glib-File-Utilities.html#g-freopen">g_freopen</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
118
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *mode,
108
int <a class="link" href="glib-File-Utilities.html#g-stat" title="g_stat ()">g_stat</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
110
int <a class="link" href="glib-File-Utilities.html#g-lstat" title="g_lstat ()">g_lstat</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
112
int <a class="link" href="glib-File-Utilities.html#g-unlink" title="g_unlink ()">g_unlink</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename);
113
int <a class="link" href="glib-File-Utilities.html#g-remove" title="g_remove ()">g_remove</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename);
114
int <a class="link" href="glib-File-Utilities.html#g-rmdir" title="g_rmdir ()">g_rmdir</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename);
115
FILE * <a class="link" href="glib-File-Utilities.html#g-fopen" title="g_fopen ()">g_fopen</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
116
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *mode);
117
FILE * <a class="link" href="glib-File-Utilities.html#g-freopen" title="g_freopen ()">g_freopen</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
118
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *mode,
120
int <a class="link" href="glib-File-Utilities.html#g-chmod">g_chmod</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
122
int <a class="link" href="glib-File-Utilities.html#g-access">g_access</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
124
int <a class="link" href="glib-File-Utilities.html#g-creat">g_creat</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
126
int <a class="link" href="glib-File-Utilities.html#g-chdir">g_chdir</a> (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *path);
120
int <a class="link" href="glib-File-Utilities.html#g-chmod" title="g_chmod ()">g_chmod</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
122
int <a class="link" href="glib-File-Utilities.html#g-access" title="g_access ()">g_access</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
124
int <a class="link" href="glib-File-Utilities.html#g-creat" title="g_creat ()">g_creat</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
126
int <a class="link" href="glib-File-Utilities.html#g-chdir" title="g_chdir ()">g_chdir</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *path);
127
int <a class="link" href="glib-File-Utilities.html#g-utime" title="g_utime ()">g_utime</a> (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
128
struct utimbuf *utb);
130
131
<div class="refsect1" lang="en">
131
<a name="id2864430"></a><h2>Description</h2>
132
<a name="glib-File-Utilities.description"></a><h2>Description</h2>
133
There is a group of functions which wrap the common POSIX functions
134
dealing with filenames (<a class="link" href="glib-File-Utilities.html#g-open"><code class="function">g_open()</code></a>, <a class="link" href="glib-File-Utilities.html#g-rename"><code class="function">g_rename()</code></a>, <a class="link" href="glib-File-Utilities.html#g-mkdir"><code class="function">g_mkdir()</code></a>, <a class="link" href="glib-File-Utilities.html#g-stat"><code class="function">g_stat()</code></a>,
135
<a class="link" href="glib-File-Utilities.html#g-unlink"><code class="function">g_unlink()</code></a>, <a class="link" href="glib-File-Utilities.html#g-remove"><code class="function">g_remove()</code></a>, <a class="link" href="glib-File-Utilities.html#g-fopen"><code class="function">g_fopen()</code></a>, <a class="link" href="glib-File-Utilities.html#g-freopen"><code class="function">g_freopen()</code></a>). The point of these
136
wrappers is to make it possible to handle file names with any Unicode
137
characters in them on Windows without having to use ifdefs and the
134
There is a group of functions which wrap the common POSIX functions
135
dealing with filenames (<a class="link" href="glib-File-Utilities.html#g-open" title="g_open ()"><code class="function">g_open()</code></a>, <a class="link" href="glib-File-Utilities.html#g-rename" title="g_rename ()"><code class="function">g_rename()</code></a>, <a class="link" href="glib-File-Utilities.html#g-mkdir" title="g_mkdir ()"><code class="function">g_mkdir()</code></a>, <a class="link" href="glib-File-Utilities.html#g-stat" title="g_stat ()"><code class="function">g_stat()</code></a>,
136
<a class="link" href="glib-File-Utilities.html#g-unlink" title="g_unlink ()"><code class="function">g_unlink()</code></a>, <a class="link" href="glib-File-Utilities.html#g-remove" title="g_remove ()"><code class="function">g_remove()</code></a>, <a class="link" href="glib-File-Utilities.html#g-fopen" title="g_fopen ()"><code class="function">g_fopen()</code></a>, <a class="link" href="glib-File-Utilities.html#g-freopen" title="g_freopen ()"><code class="function">g_freopen()</code></a>). The point of these
137
wrappers is to make it possible to handle file names with any Unicode
138
characters in them on Windows without having to use ifdefs and the
138
139
wide character API in the application code.
141
142
The pathname argument should be in the GLib file name encoding. On
142
143
POSIX this is the actual on-disk encoding which might correspond to
143
the locale settings of the process (or the
144
the locale settings of the process (or the
144
145
<code class="envar">G_FILENAME_ENCODING</code> environment variable), or not.
258
<td><p><span class="term"><a name="G-FILE-ERROR-NODEV:CAPS"></a><code class="literal">G_FILE_ERROR_NODEV</code></span></p></td>
258
<td><p><a name="G-FILE-ERROR-NODEV--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NODEV</code></span></p></td>
259
259
<td>This file is of a type that doesn't support
264
<td><p><span class="term"><a name="G-FILE-ERROR-ROFS:CAPS"></a><code class="literal">G_FILE_ERROR_ROFS</code></span></p></td>
264
<td><p><a name="G-FILE-ERROR-ROFS--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_ROFS</code></span></p></td>
265
265
<td>The directory containing the new link can't be
266
266
modified because it's on a read-only file system.
270
<td><p><span class="term"><a name="G-FILE-ERROR-TXTBSY:CAPS"></a><code class="literal">G_FILE_ERROR_TXTBSY</code></span></p></td>
270
<td><p><a name="G-FILE-ERROR-TXTBSY--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_TXTBSY</code></span></p></td>
271
271
<td>Text file busy.
275
<td><p><span class="term"><a name="G-FILE-ERROR-FAULT:CAPS"></a><code class="literal">G_FILE_ERROR_FAULT</code></span></p></td>
275
<td><p><a name="G-FILE-ERROR-FAULT--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_FAULT</code></span></p></td>
276
276
<td>You passed in a pointer to bad memory.
277
277
(GLib won't reliably return this, don't pass in pointers to bad
282
<td><p><span class="term"><a name="G-FILE-ERROR-LOOP:CAPS"></a><code class="literal">G_FILE_ERROR_LOOP</code></span></p></td>
282
<td><p><a name="G-FILE-ERROR-LOOP--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_LOOP</code></span></p></td>
283
283
<td>Too many levels of symbolic links were encountered
284
284
in looking up a file name. This often indicates a cycle of symbolic
289
<td><p><span class="term"><a name="G-FILE-ERROR-NOSPC:CAPS"></a><code class="literal">G_FILE_ERROR_NOSPC</code></span></p></td>
289
<td><p><a name="G-FILE-ERROR-NOSPC--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NOSPC</code></span></p></td>
290
290
<td>No space left on device; write operation on a
291
291
file failed because the disk is full.
295
<td><p><span class="term"><a name="G-FILE-ERROR-NOMEM:CAPS"></a><code class="literal">G_FILE_ERROR_NOMEM</code></span></p></td>
295
<td><p><a name="G-FILE-ERROR-NOMEM--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NOMEM</code></span></p></td>
296
296
<td>No memory available. The system cannot allocate
297
297
more virtual memory because its capacity is full.
301
<td><p><span class="term"><a name="G-FILE-ERROR-MFILE:CAPS"></a><code class="literal">G_FILE_ERROR_MFILE</code></span></p></td>
301
<td><p><a name="G-FILE-ERROR-MFILE--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_MFILE</code></span></p></td>
302
302
<td>The current process has too many files open and
303
303
can't open any more. Duplicate descriptors do count toward this
308
<td><p><span class="term"><a name="G-FILE-ERROR-NFILE:CAPS"></a><code class="literal">G_FILE_ERROR_NFILE</code></span></p></td>
308
<td><p><a name="G-FILE-ERROR-NFILE--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NFILE</code></span></p></td>
309
309
<td>There are too many distinct file openings in the
314
<td><p><span class="term"><a name="G-FILE-ERROR-BADF:CAPS"></a><code class="literal">G_FILE_ERROR_BADF</code></span></p></td>
314
<td><p><a name="G-FILE-ERROR-BADF--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_BADF</code></span></p></td>
315
315
<td>Bad file descriptor; for example, I/O on a
316
316
descriptor that has been closed or reading from a descriptor open
317
317
only for writing (or vice versa).
321
<td><p><span class="term"><a name="G-FILE-ERROR-INVAL:CAPS"></a><code class="literal">G_FILE_ERROR_INVAL</code></span></p></td>
321
<td><p><a name="G-FILE-ERROR-INVAL--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_INVAL</code></span></p></td>
322
322
<td>Invalid argument. This is used to indicate
323
323
various kinds of problems with passing the wrong argument to a
324
324
library function.
328
<td><p><span class="term"><a name="G-FILE-ERROR-PIPE:CAPS"></a><code class="literal">G_FILE_ERROR_PIPE</code></span></p></td>
328
<td><p><a name="G-FILE-ERROR-PIPE--CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_PIPE</code></span></p></td>
329
329
<td>Broken pipe; there is no process reading from the
330
330
other end of a pipe. Every library function that returns this
331
331
error code also generates a `SIGPIPE' signal; this signal
485
474
<div class="refsect2" lang="en">
486
<a name="id3166797"></a><h3>
487
<a name="g-file-get-contents"></a>g_file_get_contents ()</h3>
488
<a class="indexterm" name="id3166808"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> g_file_get_contents (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
489
<a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **contents,
490
<a class="link" href="glib-Basic-Types.html#gsize">gsize</a> *length,
491
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
475
<a name="g-file-get-contents"></a><h3>g_file_get_contents ()</h3>
476
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_file_get_contents (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
477
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **contents,
478
<a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> *length,
479
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
493
481
Reads an entire file into allocated memory, with good error
497
If the call was successful, it returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> and sets <em class="parameter"><code>contents</code></em> to the file
485
If the call was successful, it returns <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> and sets <em class="parameter"><code>contents</code></em> to the file
498
486
contents and <em class="parameter"><code>length</code></em> to the length of the file contents in bytes. The string
499
487
stored in <em class="parameter"><code>contents</code></em> will be nul-terminated, so for text files you can pass
500
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> for the <em class="parameter"><code>length</code></em> argument. If the call was not successful, it returns
501
<a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> and sets <em class="parameter"><code>error</code></em>. The error domain is <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR:CAPS"><span class="type">G_FILE_ERROR</span></a>. Possible error
502
codes are those in the <a class="link" href="glib-File-Utilities.html#GFileError"><span class="type">GFileError</span></a> enumeration. In the error case,
503
<em class="parameter"><code>contents</code></em> is set to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> and <em class="parameter"><code>length</code></em> is set to zero.</p>
488
<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> for the <em class="parameter"><code>length</code></em> argument. If the call was not successful, it returns
489
<a class="link" href="glib-Standard-Macros.html#FALSE--CAPS" title="FALSE"><code class="literal">FALSE</code></a> and sets <em class="parameter"><code>error</code></em>. The error domain is <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR--CAPS" title="G_FILE_ERROR"><span class="type">G_FILE_ERROR</span></a>. Possible error
490
codes are those in the <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> enumeration. In the error case,
491
<em class="parameter"><code>contents</code></em> is set to <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> and <em class="parameter"><code>length</code></em> is set to zero.</p>
507
494
<div class="variablelist"><table border="0">
508
495
<col align="left" valign="top">
511
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
498
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
512
499
<td> name of a file to read contents from, in the GLib file name encoding
516
<td><p><span class="term"><em class="parameter"><code>contents</code></em> :</span></p></td>
503
<td><p><span class="term"><em class="parameter"><code>contents</code></em> :</span></p></td>
517
504
<td> location to store an allocated string
521
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
522
<td> location to store length in bytes of the contents, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
526
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
527
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
531
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
532
<td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if an error occurred
508
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
509
<td> location to store length in bytes of the contents, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
513
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
514
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
518
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
519
<td> <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> on success, <a class="link" href="glib-Standard-Macros.html#FALSE--CAPS" title="FALSE"><code class="literal">FALSE</code></a> if an error occurred
575
If the call was sucessful, it returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>. If the call was not successful,
576
it returns <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> and sets <em class="parameter"><code>error</code></em>. The error domain is <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR:CAPS"><span class="type">G_FILE_ERROR</span></a>.
577
Possible error codes are those in the <a class="link" href="glib-File-Utilities.html#GFileError"><span class="type">GFileError</span></a> enumeration.</p>
561
If the call was sucessful, it returns <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a>. If the call was not successful,
562
it returns <a class="link" href="glib-Standard-Macros.html#FALSE--CAPS" title="FALSE"><code class="literal">FALSE</code></a> and sets <em class="parameter"><code>error</code></em>. The error domain is <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR--CAPS" title="G_FILE_ERROR"><span class="type">G_FILE_ERROR</span></a>.
563
Possible error codes are those in the <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> enumeration.</p>
581
566
<div class="variablelist"><table border="0">
582
567
<col align="left" valign="top">
585
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
570
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
586
571
<td> name of a file to write <em class="parameter"><code>contents</code></em> to, in the GLib file name
591
<td><p><span class="term"><em class="parameter"><code>contents</code></em> :</span></p></td>
576
<td><p><span class="term"><em class="parameter"><code>contents</code></em> :</span></p></td>
592
577
<td> string to write to the file
596
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
581
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
597
582
<td> length of <em class="parameter"><code>contents</code></em>, or -1 if <em class="parameter"><code>contents</code></em> is a nul-terminated string
601
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
602
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
586
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
587
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
606
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
607
<td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if an error occurred
591
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
592
<td> <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> on success, <a class="link" href="glib-Standard-Macros.html#FALSE--CAPS" title="FALSE"><code class="literal">FALSE</code></a> if an error occurred
613
<p class="since">Since 2.8
598
<p class="since">Since 2.8</p>
617
601
<div class="refsect2" lang="en">
618
<a name="id3167339"></a><h3>
619
<a name="g-file-test"></a>g_file_test ()</h3>
620
<a class="indexterm" name="id3167350"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> g_file_test (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
621
<a class="link" href="glib-File-Utilities.html#GFileTest">GFileTest</a> test);</pre>
602
<a name="g-file-test"></a><h3>g_file_test ()</h3>
603
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> g_file_test (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
604
<a class="link" href="glib-File-Utilities.html#GFileTest" title="enum GFileTest">GFileTest</a> test);</pre>
623
Returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if any of the tests in the bitfield <em class="parameter"><code>test</code></em> are
624
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>. For example, <code class="literal">(G_FILE_TEST_EXISTS |
625
G_FILE_TEST_IS_DIR)</code> will return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the file exists;
606
Returns <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> if any of the tests in the bitfield <em class="parameter"><code>test</code></em> are
607
<a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a>. For example, <code class="literal">(G_FILE_TEST_EXISTS |
608
G_FILE_TEST_IS_DIR)</code> will return <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the file exists;
626
609
the check whether it's a directory doesn't matter since the existence
627
test is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>. With the current set of available tests, there's no point
610
test is <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a>. With the current set of available tests, there's no point
628
611
passing in more than one test at a time.
631
Apart from <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK:CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a> all tests follow symbolic links,
632
so for a symbolic link to a regular file <a class="link" href="glib-File-Utilities.html#g-file-test"><code class="function">g_file_test()</code></a> will return
633
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> for both <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK:CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a> and <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-REGULAR:CAPS"><code class="literal">G_FILE_TEST_IS_REGULAR</code></a>.
636
Note, that for a dangling symbolic link <a class="link" href="glib-File-Utilities.html#g-file-test"><code class="function">g_file_test()</code></a> will return
637
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> for <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK:CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a> and <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> for all other flags.
640
You should never use <a class="link" href="glib-File-Utilities.html#g-file-test"><code class="function">g_file_test()</code></a> to test whether it is safe
614
Apart from <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK--CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a> all tests follow symbolic links,
615
so for a symbolic link to a regular file <a class="link" href="glib-File-Utilities.html#g-file-test" title="g_file_test ()"><code class="function">g_file_test()</code></a> will return
616
<a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> for both <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK--CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a> and <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-REGULAR--CAPS"><code class="literal">G_FILE_TEST_IS_REGULAR</code></a>.
619
Note, that for a dangling symbolic link <a class="link" href="glib-File-Utilities.html#g-file-test" title="g_file_test ()"><code class="function">g_file_test()</code></a> will return
620
<a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a> for <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK--CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a> and <a class="link" href="glib-Standard-Macros.html#FALSE--CAPS" title="FALSE"><code class="literal">FALSE</code></a> for all other flags.
623
You should never use <a class="link" href="glib-File-Utilities.html#g-file-test" title="g_file_test ()"><code class="function">g_file_test()</code></a> to test whether it is safe
641
624
to perform an operation, because there is always the possibility
642
625
of the condition changing before you actually perform the operation.
643
For example, you might think you could use <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK:CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a>
626
For example, you might think you could use <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK--CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a>
644
627
to know whether it is safe to write to a file without being
645
628
tricked into writing into a different location. It doesn't work!
736
716
<div class="refsect2" lang="en">
737
<a name="id3167833"></a><h3>
738
<a name="g-file-open-tmp"></a>g_file_open_tmp ()</h3>
739
<a class="indexterm" name="id3167844"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> g_file_open_tmp (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *tmpl,
740
<a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **name_used,
741
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
717
<a name="g-file-open-tmp"></a><h3>g_file_open_tmp ()</h3>
718
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint">gint</a> g_file_open_tmp (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *tmpl,
719
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> **name_used,
720
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
743
722
Opens a file for writing in the preferred directory for temporary
744
files (as returned by <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-get-tmp-dir"><code class="function">g_get_tmp_dir()</code></a>).
723
files (as returned by <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-get-tmp-dir" title="g_get_tmp_dir ()"><code class="function">g_get_tmp_dir()</code></a>).
747
726
<em class="parameter"><code>tmpl</code></em> should be a string in the GLib file name encoding containing
748
a sequence of six 'X' characters, as the parameter to <a class="link" href="glib-File-Utilities.html#g-mkstemp"><code class="function">g_mkstemp()</code></a>.
727
a sequence of six 'X' characters, as the parameter to <a class="link" href="glib-File-Utilities.html#g-mkstemp" title="g_mkstemp ()"><code class="function">g_mkstemp()</code></a>.
749
728
However, unlike these functions, the template should only be a
750
729
basename, no directory components are allowed. If template is
751
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, a default template is used.
730
<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, a default template is used.
754
Note that in contrast to <a class="link" href="glib-File-Utilities.html#g-mkstemp"><code class="function">g_mkstemp()</code></a> (and <code class="function">mkstemp()</code>)
733
Note that in contrast to <a class="link" href="glib-File-Utilities.html#g-mkstemp" title="g_mkstemp ()"><code class="function">g_mkstemp()</code></a> (and <code class="function">mkstemp()</code>)
755
734
<em class="parameter"><code>tmpl</code></em> is not modified, and might thus be a read-only literal string.
758
The actual name used is returned in <em class="parameter"><code>name_used</code></em> if non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. This
759
string should be freed with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when not needed any longer.
737
The actual name used is returned in <em class="parameter"><code>name_used</code></em> if non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>. This
738
string should be freed with <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> when not needed any longer.
760
739
The returned name is in the GLib file name encoding.</p>
764
742
<div class="variablelist"><table border="0">
765
743
<col align="left" valign="top">
768
<td><p><span class="term"><em class="parameter"><code>tmpl</code></em> :</span></p></td>
769
<td> Template for file name, as in <a class="link" href="glib-File-Utilities.html#g-mkstemp"><code class="function">g_mkstemp()</code></a>, basename only,
770
or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, to a default template
774
<td><p><span class="term"><em class="parameter"><code>name_used</code></em> :</span></p></td>
775
<td> location to store actual name used
779
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
780
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>
784
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
746
<td><p><span class="term"><em class="parameter"><code>tmpl</code></em> :</span></p></td>
747
<td> Template for file name, as in <a class="link" href="glib-File-Utilities.html#g-mkstemp" title="g_mkstemp ()"><code class="function">g_mkstemp()</code></a>, basename only,
748
or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, to a default template
752
<td><p><span class="term"><em class="parameter"><code>name_used</code></em> :</span></p></td>
753
<td> location to store actual name used, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
757
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
758
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
762
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
785
763
<td> A file handle (as from <code class="function">open()</code>) to
786
764
the file opened for reading and writing. The file is opened in binary
787
765
mode on platforms where there is a difference. The file handle should be
796
774
<div class="refsect2" lang="en">
797
<a name="id3168091"></a><h3>
798
<a name="g-file-read-link"></a>g_file_read_link ()</h3>
799
<a class="indexterm" name="id3168105"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_file_read_link (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
800
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
775
<a name="g-file-read-link"></a><h3>g_file_read_link ()</h3>
776
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> * g_file_read_link (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
777
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
802
779
Reads the contents of the symbolic link <em class="parameter"><code>filename</code></em> like the POSIX
803
780
<code class="function">readlink()</code> function. The returned string is in the encoding used
804
for filenames. Use <a class="link" href="glib-Character-Set-Conversion.html#g-filename-to-utf8"><code class="function">g_filename_to_utf8()</code></a> to convert it to UTF-8.</p>
781
for filenames. Use <a class="link" href="glib-Character-Set-Conversion.html#g-filename-to-utf8" title="g_filename_to_utf8 ()"><code class="function">g_filename_to_utf8()</code></a> to convert it to UTF-8.</p>
808
784
<div class="variablelist"><table border="0">
809
785
<col align="left" valign="top">
812
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
788
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
813
789
<td> the symbolic link
817
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
818
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>
793
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
794
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
822
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
798
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
823
799
<td> A newly allocated string with the contents of the symbolic link,
824
or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if an error occurred.
800
or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> if an error occurred.
830
<p class="since">Since 2.4
806
<p class="since">Since 2.4</p>
834
809
<div class="refsect2" lang="en">
835
<a name="id3168244"></a><h3>
836
<a name="g-mkdir-with-parents"></a>g_mkdir_with_parents ()</h3>
837
<a class="indexterm" name="id3168259"></a><pre class="programlisting">int g_mkdir_with_parents (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *pathname,
810
<a name="g-mkdir-with-parents"></a><h3>g_mkdir_with_parents ()</h3>
811
<pre class="programlisting">int g_mkdir_with_parents (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *pathname,
840
814
Create a directory if it doesn't already exist. Create intermediate
841
815
parent directories as needed, too.</p>
845
818
<div class="variablelist"><table border="0">
846
819
<col align="left" valign="top">
849
<td><p><span class="term"><em class="parameter"><code>pathname</code></em> :</span></p></td>
822
<td><p><span class="term"><em class="parameter"><code>pathname</code></em> :</span></p></td>
850
823
<td> a pathname in the GLib file name encoding
854
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
827
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
855
828
<td> permissions to use for newly created directories
859
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
832
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
860
833
<td> 0 if the directory already exists, or was successfully
861
834
created. Returns -1 if an error occurred, with errno set.
867
<p class="since">Since 2.8
840
<p class="since">Since 2.8</p>
871
843
<div class="refsect2" lang="en">
872
<a name="id3168351"></a><h3>
873
<a name="GDir"></a>GDir</h3>
874
<a class="indexterm" name="id3168364"></a><pre class="programlisting">typedef struct _GDir GDir;</pre>
844
<a name="GDir"></a><h3>GDir</h3>
845
<pre class="programlisting">typedef struct _GDir GDir;</pre>
876
847
An opaque structure representing an opened directory.
880
851
<div class="refsect2" lang="en">
881
<a name="id3168380"></a><h3>
882
<a name="g-dir-open"></a>g_dir_open ()</h3>
883
<a class="indexterm" name="id3168393"></a><pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GDir">GDir</a>* g_dir_open (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *path,
884
<a class="link" href="glib-Basic-Types.html#guint">guint</a> flags,
885
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
852
<a name="g-dir-open"></a><h3>g_dir_open ()</h3>
853
<pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a> * g_dir_open (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *path,
854
<a class="link" href="glib-Basic-Types.html#guint" title="guint">guint</a> flags,
855
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
887
857
Opens a directory for reading. The names of the files in the
888
directory can then be retrieved using <a class="link" href="glib-File-Utilities.html#g-dir-read-name"><code class="function">g_dir_read_name()</code></a>.</p>
858
directory can then be retrieved using <a class="link" href="glib-File-Utilities.html#g-dir-read-name" title="g_dir_read_name ()"><code class="function">g_dir_read_name()</code></a>.</p>
892
861
<div class="variablelist"><table border="0">
893
862
<col align="left" valign="top">
896
<td><p><span class="term"><em class="parameter"><code>path</code></em> :</span></p></td>
865
<td><p><span class="term"><em class="parameter"><code>path</code></em> :</span></p></td>
897
866
<td> the path to the directory you are interested in. On Unix
898
867
in the on-disk encoding. On Windows in UTF-8
902
<td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
871
<td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
903
872
<td> Currently must be set to 0. Reserved for future use.
907
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
908
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.
909
If non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, an error will be set if and only if
910
<a class="link" href="glib-File-Utilities.html#g-dir-open"><code class="function">g_dir_open()</code></a> fails.
876
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
877
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>.
878
If non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, an error will be set if and only if
879
<a class="link" href="glib-File-Utilities.html#g-dir-open" title="g_dir_open ()"><code class="function">g_dir_open()</code></a> fails.
914
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
915
<td> a newly allocated <a class="link" href="glib-File-Utilities.html#GDir"><span class="type">GDir</span></a> on success, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on failure.
916
If non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, you must free the result with <a class="link" href="glib-File-Utilities.html#g-dir-close"><code class="function">g_dir_close()</code></a>
883
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
884
<td> a newly allocated <a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="type">GDir</span></a> on success, <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> on failure.
885
If non-<a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>, you must free the result with <a class="link" href="glib-File-Utilities.html#g-dir-close" title="g_dir_close ()"><code class="function">g_dir_close()</code></a>
917
886
when you are finished with it.
954
921
<div class="refsect2" lang="en">
955
<a name="id3168698"></a><h3>
956
<a name="g-dir-rewind"></a>g_dir_rewind ()</h3>
957
<a class="indexterm" name="id3168710"></a><pre class="programlisting">void g_dir_rewind (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);</pre>
922
<a name="g-dir-rewind"></a><h3>g_dir_rewind ()</h3>
923
<pre class="programlisting">void g_dir_rewind (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a> *dir);</pre>
959
Resets the given directory. The next call to <a class="link" href="glib-File-Utilities.html#g-dir-read-name"><code class="function">g_dir_read_name()</code></a>
925
Resets the given directory. The next call to <a class="link" href="glib-File-Utilities.html#g-dir-read-name" title="g_dir_read_name ()"><code class="function">g_dir_read_name()</code></a>
960
926
will return the first entry again.</p>
964
929
<div class="variablelist"><table border="0">
965
930
<col align="left" valign="top">
967
<td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
968
<td> a <a class="link" href="glib-File-Utilities.html#GDir"><span class="type">GDir</span></a>* created by <a class="link" href="glib-File-Utilities.html#g-dir-open"><code class="function">g_dir_open()</code></a>
932
<td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
933
<td> a <a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="type">GDir</span></a>* created by <a class="link" href="glib-File-Utilities.html#g-dir-open" title="g_dir_open ()"><code class="function">g_dir_open()</code></a>
974
939
<div class="refsect2" lang="en">
975
<a name="id3168790"></a><h3>
976
<a name="g-dir-close"></a>g_dir_close ()</h3>
977
<a class="indexterm" name="id3168802"></a><pre class="programlisting">void g_dir_close (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);</pre>
940
<a name="g-dir-close"></a><h3>g_dir_close ()</h3>
941
<pre class="programlisting">void g_dir_close (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a> *dir);</pre>
979
943
Closes the directory and deallocates all related resources.</p>
983
946
<div class="variablelist"><table border="0">
984
947
<col align="left" valign="top">
986
<td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
987
<td> a <a class="link" href="glib-File-Utilities.html#GDir"><span class="type">GDir</span></a>* created by <a class="link" href="glib-File-Utilities.html#g-dir-open"><code class="function">g_dir_open()</code></a>
949
<td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
950
<td> a <a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="type">GDir</span></a>* created by <a class="link" href="glib-File-Utilities.html#g-dir-open" title="g_dir_open ()"><code class="function">g_dir_open()</code></a>
993
956
<div class="refsect2" lang="en">
994
<a name="id3168871"></a><h3>
995
<a name="GMappedFile"></a>GMappedFile</h3>
996
<a class="indexterm" name="id3168883"></a><pre class="programlisting">typedef struct _GMappedFile GMappedFile;</pre>
957
<a name="GMappedFile"></a><h3>GMappedFile</h3>
958
<pre class="programlisting">typedef struct _GMappedFile GMappedFile;</pre>
998
The <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a> represents a file mapping created with
999
<a class="link" href="glib-File-Utilities.html#g-mapped-file-new"><code class="function">g_mapped_file_new()</code></a>. It has only private members and should
960
The <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a> represents a file mapping created with
961
<a class="link" href="glib-File-Utilities.html#g-mapped-file-new" title="g_mapped_file_new ()"><code class="function">g_mapped_file_new()</code></a>. It has only private members and should
1000
962
not be accessed directly.
1004
966
<div class="refsect2" lang="en">
1005
<a name="id3168918"></a><h3>
1006
<a name="g-mapped-file-new"></a>g_mapped_file_new ()</h3>
1007
<a class="indexterm" name="id3168934"></a><pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a>* g_mapped_file_new (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1008
<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> writable,
1009
<a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre>
967
<a name="g-mapped-file-new"></a><h3>g_mapped_file_new ()</h3>
968
<pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> * g_mapped_file_new (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
969
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean">gboolean</a> writable,
970
<a class="link" href="glib-Error-Reporting.html#GError" title="GError">GError</a> **error);</pre>
1011
972
Maps a file into memory. On UNIX, this is using the <code class="function">mmap()</code> function.
1014
If <em class="parameter"><code>writable</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, the mapped buffer may be modified, otherwise
975
If <em class="parameter"><code>writable</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE--CAPS" title="TRUE"><code class="literal">TRUE</code></a>, the mapped buffer may be modified, otherwise
1015
976
it is an error to modify the mapped buffer. Modifications to the buffer
1016
977
are not visible to other processes mapping the same file, and are not
1017
978
written back to the file.
1020
981
Note that modifications of the underlying file might affect the contents
1021
of the <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>. Therefore, mapping should only be used if the file
982
of the <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>. Therefore, mapping should only be used if the file
1022
983
will not be modified, or if all modifications of the file are done
1023
atomically (e.g. using <a class="link" href="glib-File-Utilities.html#g-file-set-contents"><code class="function">g_file_set_contents()</code></a>).</p>
984
atomically (e.g. using <a class="link" href="glib-File-Utilities.html#g-file-set-contents" title="g_file_set_contents ()"><code class="function">g_file_set_contents()</code></a>).</p>
1027
987
<div class="variablelist"><table border="0">
1028
988
<col align="left" valign="top">
1031
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
991
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1032
992
<td> The path of the file to load, in the GLib filename encoding
1036
<td><p><span class="term"><em class="parameter"><code>writable</code></em> :</span></p></td>
996
<td><p><span class="term"><em class="parameter"><code>writable</code></em> :</span></p></td>
1037
997
<td> whether the mapping should be writable
1041
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
1042
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
1001
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
1002
<td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
1046
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1047
<td> a newly allocated <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a> which must be freed
1048
with <a class="link" href="glib-File-Utilities.html#g-mapped-file-free"><code class="function">g_mapped_file_free()</code></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the mapping failed.
1006
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1007
<td> a newly allocated <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a> which must be freed
1008
with <a class="link" href="glib-File-Utilities.html#g-mapped-file-free" title="g_mapped_file_free ()"><code class="function">g_mapped_file_free()</code></a>, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> if the mapping failed.
1054
<p class="since">Since 2.8
1014
<p class="since">Since 2.8</p>
1058
1017
<div class="refsect2" lang="en">
1059
<a name="id3169154"></a><h3>
1060
<a name="g-mapped-file-free"></a>g_mapped_file_free ()</h3>
1061
<a class="indexterm" name="id3169170"></a><pre class="programlisting">void g_mapped_file_free (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);</pre>
1018
<a name="g-mapped-file-free"></a><h3>g_mapped_file_free ()</h3>
1019
<pre class="programlisting">void g_mapped_file_free (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> *file);</pre>
1063
1021
Unmaps the buffer of <em class="parameter"><code>file</code></em> and frees it.</p>
1067
1024
<div class="variablelist"><table border="0">
1068
1025
<col align="left" valign="top">
1070
<td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1071
<td> a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>
1027
<td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1028
<td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1075
<p class="since">Since 2.8
1032
<p class="since">Since 2.8</p>
1079
1035
<div class="refsect2" lang="en">
1080
<a name="id3169240"></a><h3>
1081
<a name="g-mapped-file-get-length"></a>g_mapped_file_get_length ()</h3>
1082
<a class="indexterm" name="id3169255"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize">gsize</a> g_mapped_file_get_length (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);</pre>
1084
Returns the length of the contents of a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>.</p>
1036
<a name="g-mapped-file-get-length"></a><h3>g_mapped_file_get_length ()</h3>
1037
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize" title="gsize">gsize</a> g_mapped_file_get_length (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> *file);</pre>
1039
Returns the length of the contents of a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>.</p>
1088
1042
<div class="variablelist"><table border="0">
1089
1043
<col align="left" valign="top">
1092
<td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1093
<td> a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>
1046
<td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1047
<td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1097
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1051
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1098
1052
<td> the length of the contents of <em class="parameter"><code>file</code></em>.
1104
<p class="since">Since 2.8
1058
<p class="since">Since 2.8</p>
1108
1061
<div class="refsect2" lang="en">
1109
<a name="id3169344"></a><h3>
1110
<a name="g-mapped-file-get-contents"></a>g_mapped_file_get_contents ()</h3>
1111
<a class="indexterm" name="id3169360"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_mapped_file_get_contents (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);</pre>
1062
<a name="g-mapped-file-get-contents"></a><h3>g_mapped_file_get_contents ()</h3>
1063
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> * g_mapped_file_get_contents (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a> *file);</pre>
1113
Returns the contents of a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>.
1065
Returns the contents of a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>.
1116
1068
Note that the contents may not be zero-terminated,
1117
even if the <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a> is backed by a text file.</p>
1069
even if the <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a> is backed by a text file.</p>
1121
1072
<div class="variablelist"><table border="0">
1122
1073
<col align="left" valign="top">
1125
<td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1126
<td> a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>
1076
<td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1077
<td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1130
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1081
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1131
1082
<td> the contents of <em class="parameter"><code>file</code></em>.
1137
<p class="since">Since 2.8
1088
<p class="since">Since 2.8</p>
1141
1091
<div class="refsect2" lang="en">
1142
<a name="id3169461"></a><h3>
1143
<a name="g-open"></a>g_open ()</h3>
1144
<a class="indexterm" name="id3169475"></a><pre class="programlisting">int g_open (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1092
<a name="g-open"></a><h3>g_open ()</h3>
1093
<pre class="programlisting">int g_open (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
1146
1095
int mode);</pre>
1148
1097
A wrapper for the POSIX <code class="function">open()</code> function. The <code class="function">open()</code> function is
1149
used to convert a pathname into a file descriptor. Note that on
1150
POSIX systems file descriptors are implemented by the operating
1098
used to convert a pathname into a file descriptor.
1101
On POSIX systems file descriptors are implemented by the operating
1151
1102
system. On Windows, it's the C library that implements <code class="function">open()</code> and
1152
file descriptors. The actual Windows API for opening files is
1153
something different.
1156
See the C library manual for more details about <code class="function">open()</code>.</p>
1103
file descriptors. The actual Win32 API for opening files is quite
1104
different, see MSDN documentation for <code class="function">CreateFile()</code>. The Win32 API
1105
uses file handles, which are more randomish integers, not small
1106
integers like file descriptors.
1109
Because file descriptors are specific to the C library on Windows,
1110
the file descriptor returned by this function makes sense only to
1111
functions in the same C library. Thus if the GLib-using code uses a
1112
different C library than GLib does, the file descriptor returned by
1113
this function cannot be passed to C library functions like <code class="function">write()</code>
1114
or <code class="function">read()</code>.
1117
See your C library manual for more details about <code class="function">open()</code>.</p>
1160
1120
<div class="variablelist"><table border="0">
1161
1121
<col align="left" valign="top">
1164
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1124
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1165
1125
<td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1169
<td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
1170
<td> as in <code class="function">open()</code>
1174
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1175
<td> as in <code class="function">open()</code>
1179
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1129
<td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
1130
<td> as in <code class="function">open()</code>
1134
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1135
<td> as in <code class="function">open()</code>
1139
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1180
1140
<td> a new file descriptor, or -1 if an error occurred. The
1181
1141
return value can be used exactly like the return value from <code class="function">open()</code>.
1187
<p class="since">Since 2.6
1147
<p class="since">Since 2.6</p>
1191
1150
<div class="refsect2" lang="en">
1192
<a name="id3169666"></a><h3>
1193
<a name="g-rename"></a>g_rename ()</h3>
1194
<a class="indexterm" name="id3169681"></a><pre class="programlisting">int g_rename (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *oldfilename,
1195
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *newfilename);</pre>
1151
<a name="g-rename"></a><h3>g_rename ()</h3>
1152
<pre class="programlisting">int g_rename (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *oldfilename,
1153
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *newfilename);</pre>
1197
1155
A wrapper for the POSIX <code class="function">rename()</code> function. The <code class="function">rename()</code> function
1198
1156
renames a file, moving it between directories if required.
1201
1159
See your C library manual for more details about how <code class="function">rename()</code> works
1202
on your system. Note in particular that on Win9x it is not possible
1203
to rename a file if a file with the new name already exists. Also
1204
it is not possible in general on Windows to rename an open file.</p>
1160
on your system. It is not possible in general on Windows to rename
1161
a file that is open to some process.</p>
1208
1164
<div class="variablelist"><table border="0">
1209
1165
<col align="left" valign="top">
1212
<td><p><span class="term"><em class="parameter"><code>oldfilename</code></em> :</span></p></td>
1168
<td><p><span class="term"><em class="parameter"><code>oldfilename</code></em> :</span></p></td>
1213
1169
<td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1217
<td><p><span class="term"><em class="parameter"><code>newfilename</code></em> :</span></p></td>
1173
<td><p><span class="term"><em class="parameter"><code>newfilename</code></em> :</span></p></td>
1218
1174
<td> a pathname in the GLib file name encoding
1222
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1178
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1223
1179
<td> 0 if the renaming succeeded, -1 if an error occurred
1229
<p class="since">Since 2.6
1185
<p class="since">Since 2.6</p>
1233
1188
<div class="refsect2" lang="en">
1234
<a name="id3169813"></a><h3>
1235
<a name="g-mkdir"></a>g_mkdir ()</h3>
1236
<a class="indexterm" name="id3169827"></a><pre class="programlisting">int g_mkdir (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1189
<a name="g-mkdir"></a><h3>g_mkdir ()</h3>
1190
<pre class="programlisting">int g_mkdir (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
1237
1191
int mode);</pre>
1239
1193
A wrapper for the POSIX <code class="function">mkdir()</code> function. The <code class="function">mkdir()</code> function
1478
<p class="since">Since 2.6
1416
<p class="since">Since 2.6</p>
1482
1419
<div class="refsect2" lang="en">
1483
<a name="id3170774"></a><h3>
1484
<a name="g-fopen"></a>g_fopen ()</h3>
1485
<a class="indexterm" name="id3170788"></a><pre class="programlisting">FILE* g_fopen (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1486
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *mode);</pre>
1488
A wrapper for the POSIX <code class="function">fopen()</code> function. The <code class="function">fopen()</code> function opens
1489
a file and associates a new stream with it.
1492
See the C library manual for more details about <code class="function">fopen()</code>.</p>
1420
<a name="g-fopen"></a><h3>g_fopen ()</h3>
1421
<pre class="programlisting">FILE * g_fopen (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
1422
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *mode);</pre>
1424
A wrapper for the stdio <code class="function">fopen()</code> function. The <code class="function">fopen()</code> function
1425
opens a file and associates a new stream with it.
1428
Because file descriptors are specific to the C library on Windows,
1429
and a file descriptor is partof the <span class="type">FILE</span> struct, the
1430
<span class="type">FILE</span> pointer returned by this function makes sense
1431
only to functions in the same C library. Thus if the GLib-using
1432
code uses a different C library than GLib does, the
1433
<span class="type">FILE</span> pointer returned by this function cannot be
1434
passed to C library functions like <code class="function">fprintf()</code> or <code class="function">fread()</code>.
1437
See your C library manual for more details about <code class="function">fopen()</code>.</p>
1496
1440
<div class="variablelist"><table border="0">
1497
1441
<col align="left" valign="top">
1500
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1444
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1501
1445
<td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1505
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1449
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1506
1450
<td> a string describing the mode in which the file should be
1511
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1455
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1512
1456
<td> A <span class="type">FILE</span> pointer if the file was successfully
1513
opened, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if an error occurred
1457
opened, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> if an error occurred
1519
<p class="since">Since 2.6
1463
<p class="since">Since 2.6</p>
1523
1466
<div class="refsect2" lang="en">
1524
<a name="id3170929"></a><h3>
1525
<a name="g-freopen"></a>g_freopen ()</h3>
1526
<a class="indexterm" name="id3170944"></a><pre class="programlisting">FILE* g_freopen (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1527
const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *mode,
1467
<a name="g-freopen"></a><h3>g_freopen ()</h3>
1468
<pre class="programlisting">FILE * g_freopen (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
1469
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *mode,
1528
1470
FILE *stream);</pre>
1530
1472
A wrapper for the POSIX <code class="function">freopen()</code> function. The <code class="function">freopen()</code> function
1531
1473
opens a file and associates it with an existing stream.
1534
See the C library manual for more details about <code class="function">freopen()</code>.</p>
1476
See your C library manual for more details about <code class="function">freopen()</code>.</p>
1538
1479
<div class="variablelist"><table border="0">
1539
1480
<col align="left" valign="top">
1542
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1483
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1543
1484
<td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1547
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1488
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1548
1489
<td> a string describing the mode in which the file should be
1553
<td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
1554
<td> an existing stream which will be reused, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
1494
<td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
1495
<td> an existing stream which will be reused, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a>
1558
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1499
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1559
1500
<td> A <span class="type">FILE</span> pointer if the file was successfully
1560
opened, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if an error occurred.
1501
opened, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> if an error occurred.
1566
<p class="since">Since 2.6
1507
<p class="since">Since 2.6</p>
1570
1510
<div class="refsect2" lang="en">
1571
<a name="id3171118"></a><h3>
1572
<a name="g-chmod"></a>g_chmod ()</h3>
1573
<a class="indexterm" name="id3171133"></a><pre class="programlisting">int g_chmod (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1511
<a name="g-chmod"></a><h3>g_chmod ()</h3>
1512
<pre class="programlisting">int g_chmod (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
1574
1513
int mode);</pre>
1576
1515
A wrapper for the POSIX <code class="function">chmod()</code> function. The <code class="function">chmod()</code> function is
1577
used to set the permissions of a file system object. Note that on
1578
Windows the file protection mechanism is not at all POSIX-like, and
1579
the underlying <code class="function">chmod()</code> function in the C library just sets or
1580
clears the READONLY attribute. It does not touch any ACL. Software
1581
that needs to manage file permissions on Windows exactly should
1585
See the C library manual for more details about <code class="function">chmod()</code>.</p>
1516
used to set the permissions of a file system object.
1519
On Windows the file protection mechanism is not at all POSIX-like,
1520
and the underlying <code class="function">chmod()</code> function in the C library just sets or
1521
clears the FAT-style READONLY attribute. It does not touch any
1522
ACL. Software that needs to manage file permissions on Windows
1523
exactly should use the Win32 API.
1526
See your C library manual for more details about <code class="function">chmod()</code>.</p>
1589
1529
<div class="variablelist"><table border="0">
1590
1530
<col align="left" valign="top">
1593
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1533
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1594
1534
<td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1598
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1538
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1599
1539
<td> as in <code class="function">chmod()</code>
1603
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1543
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1604
1544
<td> zero if the operation succeeded, -1 on error.
1610
<p class="since">Since 2.8
1550
<p class="since">Since 2.8</p>
1614
1553
<div class="refsect2" lang="en">
1615
<a name="id3171285"></a><h3>
1616
<a name="g-access"></a>g_access ()</h3>
1617
<a class="indexterm" name="id3171299"></a><pre class="programlisting">int g_access (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1554
<a name="g-access"></a><h3>g_access ()</h3>
1555
<pre class="programlisting">int g_access (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
1618
1556
int mode);</pre>
1620
1558
A wrapper for the POSIX <code class="function">access()</code> function. This function is used to
1621
1559
test a pathname for one or several of read, write or execute
1622
permissions, or just existence. On Windows, the underlying <code class="function">access()</code>
1623
function in the C library only checks the READONLY attribute, and
1624
does not look at the ACL at all. Software that needs to handle file
1625
permissions on Windows more exactly should use the Win32 API.
1628
See the C library manual for more details about <code class="function">access()</code>.</p>
1560
permissions, or just existence.
1563
On Windows, the file protection mechanism is not at all POSIX-like,
1564
and the underlying function in the C library only checks the
1565
FAT-style READONLY attribute, and does not look at the ACL of a
1566
file at all. This function is this in practise almost useless on
1567
Windows. Software that needs to handle file permissions on Windows
1568
more exactly should use the Win32 API.
1571
See your C library manual for more details about <code class="function">access()</code>.</p>
1632
1574
<div class="variablelist"><table border="0">
1633
1575
<col align="left" valign="top">
1636
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1578
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1637
1579
<td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1641
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1583
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1642
1584
<td> as in <code class="function">access()</code>
1646
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1588
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1647
1589
<td> zero if the pathname refers to an existing file system
1648
1590
object that has all the tested permissions, or -1 otherwise or on
1655
<p class="since">Since 2.8
1597
<p class="since">Since 2.8</p>
1659
1600
<div class="refsect2" lang="en">
1660
<a name="id3171440"></a><h3>
1661
<a name="g-creat"></a>g_creat ()</h3>
1662
<a class="indexterm" name="id3171455"></a><pre class="programlisting">int g_creat (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,
1601
<a name="g-creat"></a><h3>g_creat ()</h3>
1602
<pre class="programlisting">int g_creat (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar">gchar</a> *filename,
1663
1603
int mode);</pre>
1665
1605
A wrapper for the POSIX <code class="function">creat()</code> function. The <code class="function">creat()</code> function is
1666
1606
used to convert a pathname into a file descriptor, creating a file
1667
if necessary. Note that on POSIX systems file descriptors are
1668
implemented by the operating system. On Windows, it's the C library
1669
that implements <code class="function">creat()</code> and file descriptors. The actual Windows
1670
API for opening files is something different.
1673
See the C library manual for more details about <code class="function">creat()</code>.</p>
1610
On POSIX systems file descriptors are implemented by the operating
1611
system. On Windows, it's the C library that implements <code class="function">creat()</code> and
1612
file descriptors. The actual Windows API for opening files is
1613
different, see MSDN documentation for <code class="function">CreateFile()</code>. The Win32 API
1614
uses file handles, which are more randomish integers, not small
1615
integers like file descriptors.
1618
Because file descriptors are specific to the C library on Windows,
1619
the file descriptor returned by this function makes sense only to
1620
functions in the same C library. Thus if the GLib-using code uses a
1621
different C library than GLib does, the file descriptor returned by
1622
this function cannot be passed to C library functions like <code class="function">write()</code>
1623
or <code class="function">read()</code>.
1626
See your C library manual for more details about <code class="function">creat()</code>.</p>
1677
1629
<div class="variablelist"><table border="0">
1678
1630
<col align="left" valign="top">
1681
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1633
<td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1682
1634
<td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1686
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1638
<td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1687
1639
<td> as in <code class="function">creat()</code>
1691
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1643
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1692
1644
<td> a new file descriptor, or -1 if an error occurred. The
1693
1645
return value can be used exactly like the return value from <code class="function">creat()</code>.