Initial commit
[platform/upstream/glib2.0.git] / docs / reference / glib / html / glib-File-Utilities.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>File Utilities</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-utilities.html" title="GLib Utilities">
9 <link rel="prev" href="glib-Spawning-Processes.html" title="Spawning Processes">
10 <link rel="next" href="glib-URI-Functions.html" title="URI Functions">
11 <meta name="generator" content="GTK-Doc V1.13 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 <link rel="chapter" href="glib.html" title="GLib Overview">
14 <link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
15 <link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
16 <link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
17 <link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
18 <link rel="chapter" href="tools.html" title="GLib Tools">
19 <link rel="index" href="api-index-full.html" title="Index">
20 <link rel="index" href="api-index-deprecated.html" title="Index of deprecated symbols">
21 <link rel="index" href="api-index-2-2.html" title="Index of new symbols in 2.2">
22 <link rel="index" href="api-index-2-4.html" title="Index of new symbols in 2.4">
23 <link rel="index" href="api-index-2-6.html" title="Index of new symbols in 2.6">
24 <link rel="index" href="api-index-2-8.html" title="Index of new symbols in 2.8">
25 <link rel="index" href="api-index-2-10.html" title="Index of new symbols in 2.10">
26 <link rel="index" href="api-index-2-12.html" title="Index of new symbols in 2.12">
27 <link rel="index" href="api-index-2-14.html" title="Index of new symbols in 2.14">
28 <link rel="index" href="api-index-2-16.html" title="Index of new symbols in 2.16">
29 <link rel="index" href="api-index-2-18.html" title="Index of new symbols in 2.18">
30 <link rel="index" href="api-index-2-20.html" title="Index of new symbols in 2.20">
31 <link rel="index" href="api-index-2-22.html" title="Index of new symbols in 2.22">
32 <link rel="index" href="api-index-2-24.html" title="Index of new symbols in 2.24">
33 </head>
34 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
35 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
36 <tr valign="middle">
37 <td><a accesskey="p" href="glib-Spawning-Processes.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
38 <td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
39 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
40 <th width="100%" align="center">GLib Reference Manual</th>
41 <td><a accesskey="n" href="glib-URI-Functions.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
42 </tr>
43 <tr><td colspan="5" class="shortcuts">
44 <a href="#glib-File-Utilities.synopsis" class="shortcut">Top</a>
45                    | 
46                   <a href="#glib-File-Utilities.description" class="shortcut">Description</a>
47 </td></tr>
48 </table>
49 <div class="refentry" title="File Utilities">
50 <a name="glib-File-Utilities"></a><div class="titlepage"></div>
51 <div class="refnamediv"><table width="100%"><tr>
52 <td valign="top">
53 <h2><span class="refentrytitle"><a name="glib-File-Utilities.top_of_page"></a>File Utilities</span></h2>
54 <p>File Utilities — various file-related functions</p>
55 </td>
56 <td valign="top" align="right"></td>
57 </tr></table></div>
58 <div class="refsynopsisdiv" title="Synopsis">
59 <a name="glib-File-Utilities.synopsis"></a><h2>Synopsis</h2>
60 <pre class="synopsis">
61 #include &lt;glib.h&gt;
62 #include &lt;glib/gstdio.h&gt;
63
64 enum                <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError">GFileError</a>;
65 #define             <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR:CAPS" title="G_FILE_ERROR">G_FILE_ERROR</a>
66 enum                <a class="link" href="glib-File-Utilities.html#GFileTest" title="enum GFileTest">GFileTest</a>;
67 <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="returnvalue">GFileError</span></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"><span class="returnvalue">gint</span></a> err_no);
68 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></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"><span class="returnvalue">gchar</span></a> *filename,
69                                                          <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **contents,
70                                                          <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> *length,
71                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
72 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></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"><span class="returnvalue">gchar</span></a> *filename,
73                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *contents,
74                                                          <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> length,
75                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
76 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></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"><span class="returnvalue">gchar</span></a> *filename,
77                                                          <a class="link" href="glib-File-Utilities.html#GFileTest" title="enum GFileTest"><span class="returnvalue">GFileTest</span></a> test);
78 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></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"><span class="returnvalue">gchar</span></a> *tmpl);
79 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-File-Utilities.html#g-mkstemp-full" title="g_mkstemp_full ()">g_mkstemp_full</a>                      (<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *tmpl,
80                                                          <span class="returnvalue">int</span> flags,
81                                                          <span class="returnvalue">int</span> mode);
82 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></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"><span class="returnvalue">gchar</span></a> *tmpl,
83                                                          <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **name_used,
84                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
85 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></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"><span class="returnvalue">gchar</span></a> *filename,
86                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
87 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *pathname,
88                                                          <span class="returnvalue">int</span> mode);
89
90                     <a class="link" href="glib-File-Utilities.html#GDir" title="GDir">GDir</a>;
91 <a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="returnvalue">GDir</span></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"><span class="returnvalue">gchar</span></a> *path,
92                                                          <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a> flags,
93                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
94 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></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"><span class="returnvalue">GDir</span></a> *dir);
95 <span class="returnvalue">void</span>                <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"><span class="returnvalue">GDir</span></a> *dir);
96 <span class="returnvalue">void</span>                <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"><span class="returnvalue">GDir</span></a> *dir);
97
98                     <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile">GMappedFile</a>;
99 <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></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"><span class="returnvalue">gchar</span></a> *filename,
100                                                          <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> writable,
101                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);
102 <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *       <a class="link" href="glib-File-Utilities.html#g-mapped-file-ref" title="g_mapped_file_ref ()">g_mapped_file_ref</a>                   (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *file);
103 <span class="returnvalue">void</span>                <a class="link" href="glib-File-Utilities.html#g-mapped-file-unref" title="g_mapped_file_unref ()">g_mapped_file_unref</a>                 (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *file);
104 <span class="returnvalue">void</span>                <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"><span class="returnvalue">GMappedFile</span></a> *file);
105 <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></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"><span class="returnvalue">GMappedFile</span></a> *file);
106 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></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"><span class="returnvalue">GMappedFile</span></a> *file);
107
108 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
109                                                          <span class="returnvalue">int</span> flags,
110                                                          <span class="returnvalue">int</span> mode);
111 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *oldfilename,
112                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *newfilename);
113 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
114                                                          <span class="returnvalue">int</span> mode);
115 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
116                                                          <span class="returnvalue">struct _g_stat_struct</span> *buf);
117 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
118                                                          <span class="returnvalue">struct _g_stat_struct</span> *buf);
119 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename);
120 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename);
121 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename);
122 <span class="returnvalue">FILE</span> *              <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"><span class="returnvalue">gchar</span></a> *filename,
123                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *mode);
124 <span class="returnvalue">FILE</span> *              <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"><span class="returnvalue">gchar</span></a> *filename,
125                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *mode,
126                                                          <span class="returnvalue">FILE</span> *stream);
127 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
128                                                          <span class="returnvalue">int</span> mode);
129 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
130                                                          <span class="returnvalue">int</span> mode);
131 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
132                                                          <span class="returnvalue">int</span> mode);
133 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *path);
134 <span class="returnvalue">int</span>                 <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"><span class="returnvalue">gchar</span></a> *filename,
135                                                          <span class="returnvalue">struct utimbuf</span> *utb);
136 </pre>
137 </div>
138 <div class="refsect1" title="Description">
139 <a name="glib-File-Utilities.description"></a><h2>Description</h2>
140 <p>
141 There is a group of functions which wrap the common POSIX functions
142 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>,
143 <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
144 wrappers is to make it possible to handle file names with any Unicode
145 characters in them on Windows without having to use ifdefs and the
146 wide character API in the application code.
147 </p>
148 <p>
149 The pathname argument should be in the GLib file name encoding. On
150 POSIX this is the actual on-disk encoding which might correspond to
151 the locale settings of the process (or the
152 <code class="envar">G_FILENAME_ENCODING</code> environment variable), or not.
153 </p>
154 <p>
155 On Windows the GLib file name encoding is UTF-8. Note that the
156 Microsoft C library does not use UTF-8, but has separate APIs for
157 current system code page and wide characters (UTF-16). The GLib
158 wrappers call the wide character API if present (on modern Windows
159 systems), otherwise convert to/from the system code page.
160 </p>
161 <p>
162 Another group of functions allows to open and read directories
163 in the GLib file name encoding. These are <a class="link" href="glib-File-Utilities.html#g-dir-open" title="g_dir_open ()"><code class="function">g_dir_open()</code></a>,
164 <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>, <a class="link" href="glib-File-Utilities.html#g-dir-rewind" title="g_dir_rewind ()"><code class="function">g_dir_rewind()</code></a>, <a class="link" href="glib-File-Utilities.html#g-dir-close" title="g_dir_close ()"><code class="function">g_dir_close()</code></a>.
165 </p>
166 </div>
167 <div class="refsect1" title="Details">
168 <a name="glib-File-Utilities.details"></a><h2>Details</h2>
169 <div class="refsect2" title="enum GFileError">
170 <a name="GFileError"></a><h3>enum GFileError</h3>
171 <pre class="programlisting">typedef enum
172 {
173   G_FILE_ERROR_EXIST,
174   G_FILE_ERROR_ISDIR,
175   G_FILE_ERROR_ACCES,
176   G_FILE_ERROR_NAMETOOLONG,
177   G_FILE_ERROR_NOENT,
178   G_FILE_ERROR_NOTDIR,
179   G_FILE_ERROR_NXIO,
180   G_FILE_ERROR_NODEV,
181   G_FILE_ERROR_ROFS,
182   G_FILE_ERROR_TXTBSY,
183   G_FILE_ERROR_FAULT,
184   G_FILE_ERROR_LOOP,
185   G_FILE_ERROR_NOSPC,
186   G_FILE_ERROR_NOMEM,
187   G_FILE_ERROR_MFILE,
188   G_FILE_ERROR_NFILE,
189   G_FILE_ERROR_BADF,
190   G_FILE_ERROR_INVAL,
191   G_FILE_ERROR_PIPE,
192   G_FILE_ERROR_AGAIN,
193   G_FILE_ERROR_INTR,
194   G_FILE_ERROR_IO,
195   G_FILE_ERROR_PERM,
196   G_FILE_ERROR_NOSYS,
197   G_FILE_ERROR_FAILED
198 } GFileError;
199 </pre>
200 <p>
201 Values corresponding to <code class="literal">errno</code> codes returned from file operations
202 on UNIX. Unlike <code class="literal">errno</code> codes, <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> values are available on
203 all systems, even Windows. The exact meaning of each code depends on what
204 sort of file operation you were performing; the UNIX documentation
205 gives more details. The following error code descriptions come
206 from the GNU C Library manual, and are under the copyright
207 of that manual.
208 </p>
209 <p>
210 It's not very portable to make detailed assumptions about exactly
211 which errors will be returned from a given operation. Some errors
212 don't occur on some systems, etc., sometimes there are subtle
213 differences in when a system will report a given error, etc.
214 </p>
215 <div class="variablelist"><table border="0">
216 <col align="left" valign="top">
217 <tbody>
218 <tr>
219 <td><p><a name="G-FILE-ERROR-EXIST:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_EXIST</code></span></p></td>
220 <td>Operation not permitted; only the owner of the
221      file (or other resource) or processes with special privileges can
222      perform the operation.
223 </td>
224 </tr>
225 <tr>
226 <td><p><a name="G-FILE-ERROR-ISDIR:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_ISDIR</code></span></p></td>
227 <td>File is a directory; you cannot open a directory
228      for writing, or create or remove hard links to it.
229 </td>
230 </tr>
231 <tr>
232 <td><p><a name="G-FILE-ERROR-ACCES:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_ACCES</code></span></p></td>
233 <td>Permission denied; the file permissions do not
234      allow the attempted operation.
235 </td>
236 </tr>
237 <tr>
238 <td><p><a name="G-FILE-ERROR-NAMETOOLONG:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NAMETOOLONG</code></span></p></td>
239 <td>Filename too long.
240 </td>
241 </tr>
242 <tr>
243 <td><p><a name="G-FILE-ERROR-NOENT:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NOENT</code></span></p></td>
244 <td>No such file or directory.  This is a "file
245      doesn't exist" error for ordinary files that are referenced in
246      contexts where they are expected to already exist.
247 </td>
248 </tr>
249 <tr>
250 <td><p><a name="G-FILE-ERROR-NOTDIR:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NOTDIR</code></span></p></td>
251 <td>A file that isn't a directory was specified when
252      a directory is required.
253 </td>
254 </tr>
255 <tr>
256 <td><p><a name="G-FILE-ERROR-NXIO:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NXIO</code></span></p></td>
257 <td>No such device or address.  The system tried to
258      use the device represented by a file you specified, and it
259      couldn't find the device.  This can mean that the device file was
260      installed incorrectly, or that the physical device is missing or
261      not correctly attached to the computer.
262 </td>
263 </tr>
264 <tr>
265 <td><p><a name="G-FILE-ERROR-NODEV:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NODEV</code></span></p></td>
266 <td>This file is of a type that doesn't support
267      mapping.
268 </td>
269 </tr>
270 <tr>
271 <td><p><a name="G-FILE-ERROR-ROFS:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_ROFS</code></span></p></td>
272 <td>The directory containing the new link can't be
273           modified because it's on a read-only file system.
274 </td>
275 </tr>
276 <tr>
277 <td><p><a name="G-FILE-ERROR-TXTBSY:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_TXTBSY</code></span></p></td>
278 <td>Text file busy.
279 </td>
280 </tr>
281 <tr>
282 <td><p><a name="G-FILE-ERROR-FAULT:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_FAULT</code></span></p></td>
283 <td>You passed in a pointer to bad memory.
284   (GLib won't reliably return this, don't pass in pointers to bad
285   memory.)
286 </td>
287 </tr>
288 <tr>
289 <td><p><a name="G-FILE-ERROR-LOOP:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_LOOP</code></span></p></td>
290 <td>Too many levels of symbolic links were encountered
291   in looking up a file name.  This often indicates a cycle of symbolic
292   links.
293 </td>
294 </tr>
295 <tr>
296 <td><p><a name="G-FILE-ERROR-NOSPC:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NOSPC</code></span></p></td>
297 <td>No space left on device; write operation on a
298   file failed because the disk is full.
299 </td>
300 </tr>
301 <tr>
302 <td><p><a name="G-FILE-ERROR-NOMEM:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NOMEM</code></span></p></td>
303 <td>No memory available.  The system cannot allocate
304      more virtual memory because its capacity is full.
305 </td>
306 </tr>
307 <tr>
308 <td><p><a name="G-FILE-ERROR-MFILE:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_MFILE</code></span></p></td>
309 <td>The current process has too many files open and
310      can't open any more.  Duplicate descriptors do count toward this
311      limit.
312 </td>
313 </tr>
314 <tr>
315 <td><p><a name="G-FILE-ERROR-NFILE:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NFILE</code></span></p></td>
316 <td>There are too many distinct file openings in the
317      entire system.
318 </td>
319 </tr>
320 <tr>
321 <td><p><a name="G-FILE-ERROR-BADF:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_BADF</code></span></p></td>
322 <td>Bad file descriptor; for example, I/O on a
323      descriptor that has been closed or reading from a descriptor open
324      only for writing (or vice versa).
325 </td>
326 </tr>
327 <tr>
328 <td><p><a name="G-FILE-ERROR-INVAL:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_INVAL</code></span></p></td>
329 <td>Invalid argument.  This is used to indicate
330      various kinds of problems with passing the wrong argument to a
331      library function.
332 </td>
333 </tr>
334 <tr>
335 <td><p><a name="G-FILE-ERROR-PIPE:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_PIPE</code></span></p></td>
336 <td>Broken pipe; there is no process reading from the
337      other end of a pipe.  Every library function that returns this
338      error code also generates a `SIGPIPE' signal; this signal
339      terminates the program if not handled or blocked.  Thus, your
340      program will never actually see this code unless it has handled or
341      blocked `SIGPIPE'.
342 </td>
343 </tr>
344 <tr>
345 <td><p><a name="G-FILE-ERROR-AGAIN:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_AGAIN</code></span></p></td>
346 <td>Resource temporarily unavailable; the call might
347      work if you try again later.
348 </td>
349 </tr>
350 <tr>
351 <td><p><a name="G-FILE-ERROR-INTR:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_INTR</code></span></p></td>
352 <td>Interrupted function call; an asynchronous signal
353      occurred and prevented completion of the call.  When this
354      happens, you should try the call again.
355 </td>
356 </tr>
357 <tr>
358 <td><p><a name="G-FILE-ERROR-IO:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_IO</code></span></p></td>
359 <td>Input/output error; usually used for physical read
360     or write errors. i.e. the disk or other physical device hardware
361     is returning errors.
362 </td>
363 </tr>
364 <tr>
365 <td><p><a name="G-FILE-ERROR-PERM:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_PERM</code></span></p></td>
366 <td>Operation not permitted; only the owner of the
367      file (or other resource) or processes with special privileges can
368      perform the operation.
369 </td>
370 </tr>
371 <tr>
372 <td><p><a name="G-FILE-ERROR-NOSYS:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_NOSYS</code></span></p></td>
373 <td>Function not implemented; this indicates that the
374     system is missing some functionality.
375 </td>
376 </tr>
377 <tr>
378 <td><p><a name="G-FILE-ERROR-FAILED:CAPS"></a><span class="term"><code class="literal">G_FILE_ERROR_FAILED</code></span></p></td>
379 <td>Does not correspond to a UNIX error code; this
380   is the standard "failed for unspecified reason" error code present in
381   all <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> error code enumerations. Returned if no specific
382   code applies.
383 </td>
384 </tr>
385 </tbody>
386 </table></div>
387 </div>
388 <hr>
389 <div class="refsect2" title="G_FILE_ERROR">
390 <a name="G-FILE-ERROR:CAPS"></a><h3>G_FILE_ERROR</h3>
391 <pre class="programlisting">#define G_FILE_ERROR g_file_error_quark ()
392 </pre>
393 <p>
394 Error domain for file operations. Errors in this domain will
395 be from the <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> enumeration. See <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> for information on
396 error domains.
397 </p>
398 </div>
399 <hr>
400 <div class="refsect2" title="enum GFileTest">
401 <a name="GFileTest"></a><h3>enum GFileTest</h3>
402 <pre class="programlisting">typedef enum
403 {
404   G_FILE_TEST_IS_REGULAR    = 1 &lt;&lt; 0,
405   G_FILE_TEST_IS_SYMLINK    = 1 &lt;&lt; 1,
406   G_FILE_TEST_IS_DIR        = 1 &lt;&lt; 2,
407   G_FILE_TEST_IS_EXECUTABLE = 1 &lt;&lt; 3,
408   G_FILE_TEST_EXISTS        = 1 &lt;&lt; 4
409 } GFileTest;
410 </pre>
411 <p>
412 A test to perform on a file using <a class="link" href="glib-File-Utilities.html#g-file-test" title="g_file_test ()"><code class="function">g_file_test()</code></a>.
413 </p>
414 <div class="variablelist"><table border="0">
415 <col align="left" valign="top">
416 <tbody>
417 <tr>
418 <td><p><a name="G-FILE-TEST-IS-REGULAR:CAPS"></a><span class="term"><code class="literal">G_FILE_TEST_IS_REGULAR</code></span></p></td>
419 <td>
420 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the file is a regular file (not a directory).
421     Note that this test will also return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the tested file is a symlink
422     to a regular file.
423 </td>
424 </tr>
425 <tr>
426 <td><p><a name="G-FILE-TEST-IS-SYMLINK:CAPS"></a><span class="term"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></span></p></td>
427 <td>
428 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the file is a symlink.
429 </td>
430 </tr>
431 <tr>
432 <td><p><a name="G-FILE-TEST-IS-DIR:CAPS"></a><span class="term"><code class="literal">G_FILE_TEST_IS_DIR</code></span></p></td>
433 <td>
434 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the file is a directory.
435 </td>
436 </tr>
437 <tr>
438 <td><p><a name="G-FILE-TEST-IS-EXECUTABLE:CAPS"></a><span class="term"><code class="literal">G_FILE_TEST_IS_EXECUTABLE</code></span></p></td>
439 <td>
440 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the file is executable.
441 </td>
442 </tr>
443 <tr>
444 <td><p><a name="G-FILE-TEST-EXISTS:CAPS"></a><span class="term"><code class="literal">G_FILE_TEST_EXISTS</code></span></p></td>
445 <td>
446 <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the file exists. 
447     It may or may not be a regular file.
448 </td>
449 </tr>
450 </tbody>
451 </table></div>
452 </div>
453 <hr>
454 <div class="refsect2" title="g_file_error_from_errno ()">
455 <a name="g-file-error-from-errno"></a><h3>g_file_error_from_errno ()</h3>
456 <pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="returnvalue">GFileError</span></a>          g_file_error_from_errno             (<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a> err_no);</pre>
457 <p>
458 Gets a <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> constant based on the passed-in <em class="parameter"><code>errno</code></em>.
459 For example, if you pass in <code class="literal">EEXIST</code> this function returns
460 <a class="link" href="glib-File-Utilities.html#G-FILE-ERROR-EXIST:CAPS"><span class="type">G_FILE_ERROR_EXIST</span></a>. Unlike <em class="parameter"><code>errno</code></em> values, you can portably
461 assume that all <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> values will exist.
462 </p>
463 <p>
464 Normally a <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> value goes into a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a> returned
465 from a function that manipulates files. So you would use
466 <a class="link" href="glib-File-Utilities.html#g-file-error-from-errno" title="g_file_error_from_errno ()"><code class="function">g_file_error_from_errno()</code></a> when constructing a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>.</p>
467 <div class="variablelist"><table border="0">
468 <col align="left" valign="top">
469 <tbody>
470 <tr>
471 <td><p><span class="term"><em class="parameter"><code>err_no</code></em> :</span></p></td>
472 <td> an "errno" value
473 </td>
474 </tr>
475 <tr>
476 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
477 <td> <a class="link" href="glib-File-Utilities.html#GFileError" title="enum GFileError"><span class="type">GFileError</span></a> corresponding to the given <em class="parameter"><code>errno</code></em>
478 </td>
479 </tr>
480 </tbody>
481 </table></div>
482 </div>
483 <hr>
484 <div class="refsect2" title="g_file_get_contents ()">
485 <a name="g-file-get-contents"></a><h3>g_file_get_contents ()</h3>
486 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_file_get_contents                 (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
487                                                          <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **contents,
488                                                          <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> *length,
489                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
490 <p>
491 Reads an entire file into allocated memory, with good error
492 checking.
493 </p>
494 <p>
495 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
496 contents and <em class="parameter"><code>length</code></em> to the length of the file contents in bytes. The string
497 stored in <em class="parameter"><code>contents</code></em> will be nul-terminated, so for text files you can pass
498 <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
499 <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
500 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,
501 <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>
502 <div class="variablelist"><table border="0">
503 <col align="left" valign="top">
504 <tbody>
505 <tr>
506 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
507 <td> name of a file to read contents from, in the GLib file name encoding
508 </td>
509 </tr>
510 <tr>
511 <td><p><span class="term"><em class="parameter"><code>contents</code></em> :</span></p></td>
512 <td> location to store an allocated string, use <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> to free
513     the returned string
514 </td>
515 </tr>
516 <tr>
517 <td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
518 <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>
519 </td>
520 </tr>
521 <tr>
522 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
523 <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>
524 </td>
525 </tr>
526 <tr>
527 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
528 <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
529 </td>
530 </tr>
531 </tbody>
532 </table></div>
533 </div>
534 <hr>
535 <div class="refsect2" title="g_file_set_contents ()">
536 <a name="g-file-set-contents"></a><h3>g_file_set_contents ()</h3>
537 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_file_set_contents                 (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
538                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *contents,
539                                                          <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> length,
540                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
541 <p>
542 Writes all of <em class="parameter"><code>contents</code></em> to a file named <em class="parameter"><code>filename</code></em>, with good error checking.
543 If a file called <em class="parameter"><code>filename</code></em> already exists it will be overwritten.
544 </p>
545 <p>
546 This write is atomic in the sense that it is first written to a temporary
547 file which is then renamed to the final name. Notes:
548 </p>
549 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
550 <li class="listitem">
551    On Unix, if <em class="parameter"><code>filename</code></em> already exists hard links to <em class="parameter"><code>filename</code></em> will break.
552    Also since the file is recreated, existing permissions, access control
553    lists, metadata etc. may be lost. If <em class="parameter"><code>filename</code></em> is a symbolic link,
554    the link itself will be replaced, not the linked file.
555 </li>
556 <li class="listitem">
557   On Windows renaming a file will not remove an existing file with the
558   new name, so on Windows there is a race condition between the existing
559   file being removed and the temporary file being renamed.
560 </li>
561 <li class="listitem">
562   On Windows there is no way to remove a file that is open to some
563   process, or mapped into memory. Thus, this function will fail if
564   <em class="parameter"><code>filename</code></em> already exists and is open.
565 </li>
566 </ul></div>
567 <p>
568 </p>
569 <p>
570 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,
571 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>.
572 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>
573 <div class="variablelist"><table border="0">
574 <col align="left" valign="top">
575 <tbody>
576 <tr>
577 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
578 <td> name of a file to write <em class="parameter"><code>contents</code></em> to, in the GLib file name
579   encoding
580 </td>
581 </tr>
582 <tr>
583 <td><p><span class="term"><em class="parameter"><code>contents</code></em> :</span></p></td>
584 <td> string to write to the file
585 </td>
586 </tr>
587 <tr>
588 <td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
589 <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
590 </td>
591 </tr>
592 <tr>
593 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
594 <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>
595 </td>
596 </tr>
597 <tr>
598 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
599 <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
600
601 </td>
602 </tr>
603 </tbody>
604 </table></div>
605 <p class="since">Since 2.8</p>
606 </div>
607 <hr>
608 <div class="refsect2" title="g_file_test ()">
609 <a name="g-file-test"></a><h3>g_file_test ()</h3>
610 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_file_test                         (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
611                                                          <a class="link" href="glib-File-Utilities.html#GFileTest" title="enum GFileTest"><span class="returnvalue">GFileTest</span></a> test);</pre>
612 <p>
613 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
614 <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 | 
615 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; 
616 the check whether it's a directory doesn't matter since the existence 
617 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
618 passing in more than one test at a time.
619 </p>
620 <p>
621 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,
622 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
623 <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>.
624 </p>
625 <p>
626 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
627 <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.
628 </p>
629 <p>
630 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
631 to perform an operation, because there is always the possibility
632 of the condition changing before you actually perform the operation.
633 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>
634 to know whether it is safe to write to a file without being
635 tricked into writing into a different location. It doesn't work!
636 </p>
637 <div class="informalexample"><pre class="programlisting">
638 /* DON'T DO THIS */
639  if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK)) 
640    {
641      fd = g_open (filename, O_WRONLY);
642      /* write to fd */
643    }
644 </pre></div>
645 <p>
646 </p>
647 <p>
648 Another thing to note is that <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-EXISTS:CAPS"><code class="literal">G_FILE_TEST_EXISTS</code></a> and
649 <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-EXECUTABLE:CAPS"><code class="literal">G_FILE_TEST_IS_EXECUTABLE</code></a> are implemented using the <code class="function">access()</code>
650 system call. This usually doesn't matter, but if your program
651 is setuid or setgid it means that these tests will give you
652 the answer for the real user ID and group ID, rather than the
653 effective user ID and group ID.
654 </p>
655 <p>
656 On Windows, there are no symlinks, so testing for
657 <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-SYMLINK:CAPS"><code class="literal">G_FILE_TEST_IS_SYMLINK</code></a> will always return <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>. Testing for
658 <a class="link" href="glib-File-Utilities.html#G-FILE-TEST-IS-EXECUTABLE:CAPS"><code class="literal">G_FILE_TEST_IS_EXECUTABLE</code></a> will just check that the file exists and
659 its name indicates that it is executable, checking for well-known
660 extensions and those listed in the <code class="literal">PATHEXT</code> environment variable.</p>
661 <div class="variablelist"><table border="0">
662 <col align="left" valign="top">
663 <tbody>
664 <tr>
665 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
666 <td> a filename to test in the GLib file name encoding
667 </td>
668 </tr>
669 <tr>
670 <td><p><span class="term"><em class="parameter"><code>test</code></em> :</span></p></td>
671 <td> bitfield of <a class="link" href="glib-File-Utilities.html#GFileTest" title="enum GFileTest"><span class="type">GFileTest</span></a> flags
672 </td>
673 </tr>
674 <tr>
675 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
676 <td> whether a test was <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>
677 </td>
678 </tr>
679 </tbody>
680 </table></div>
681 </div>
682 <hr>
683 <div class="refsect2" title="g_mkstemp ()">
684 <a name="g-mkstemp"></a><h3>g_mkstemp ()</h3>
685 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_mkstemp                           (<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *tmpl);</pre>
686 <p>
687 Opens a temporary file. See the <code class="function">mkstemp()</code> documentation
688 on most UNIX-like systems. 
689 </p>
690 <p>
691 The parameter is a string that should follow the rules for
692 <code class="function">mkstemp()</code> templates, i.e. contain the string "XXXXXX". 
693 <a class="link" href="glib-File-Utilities.html#g-mkstemp" title="g_mkstemp ()"><code class="function">g_mkstemp()</code></a> is slightly more flexible than <code class="function">mkstemp()</code>
694 in that the sequence does not have to occur at the very end of the 
695 template. The X string will 
696 be modified to form the name of a file that didn't exist.
697 The string should be in the GLib file name encoding. Most importantly, 
698 on Windows it should be in UTF-8.</p>
699 <div class="variablelist"><table border="0">
700 <col align="left" valign="top">
701 <tbody>
702 <tr>
703 <td><p><span class="term"><em class="parameter"><code>tmpl</code></em> :</span></p></td>
704 <td> template filename
705 </td>
706 </tr>
707 <tr>
708 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
709 <td> A file handle (as from <code class="function">open()</code>) to the file
710 opened for reading and writing. The file is opened in binary mode
711 on platforms where there is a difference. The file handle should be
712 closed with <code class="function">close()</code>. In case of errors, -1 is returned.  
713 </td>
714 </tr>
715 </tbody>
716 </table></div>
717 </div>
718 <hr>
719 <div class="refsect2" title="g_mkstemp_full ()">
720 <a name="g-mkstemp-full"></a><h3>g_mkstemp_full ()</h3>
721 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_mkstemp_full                      (<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *tmpl,
722                                                          <span class="returnvalue">int</span> flags,
723                                                          <span class="returnvalue">int</span> mode);</pre>
724 <p>
725 Opens a temporary file. See the <code class="function">mkstemp()</code> documentation
726 on most UNIX-like systems.
727 </p>
728 <p>
729 The parameter is a string that should follow the rules for
730 <code class="function">mkstemp()</code> templates, i.e. contain the string "XXXXXX".
731 <a class="link" href="glib-File-Utilities.html#g-mkstemp-full" title="g_mkstemp_full ()"><code class="function">g_mkstemp_full()</code></a> is slightly more flexible than <code class="function">mkstemp()</code>
732 in that the sequence does not have to occur at the very end of the
733 template and you can pass a <em class="parameter"><code>mode</code></em> and additional <em class="parameter"><code>flags</code></em>. The X
734 string will be modified to form the name of a file that didn't exist.
735 The string should be in the GLib file name encoding. Most importantly,
736 on Windows it should be in UTF-8.</p>
737 <div class="variablelist"><table border="0">
738 <col align="left" valign="top">
739 <tbody>
740 <tr>
741 <td><p><span class="term"><em class="parameter"><code>tmpl</code></em> :</span></p></td>
742 <td> template filename
743 </td>
744 </tr>
745 <tr>
746 <td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
747 <td> flags to pass to an <code class="function">open()</code> call in addition to O_EXCL and
748         O_CREAT, which are passed automatically
749 </td>
750 </tr>
751 <tr>
752 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
753 <td> permissios to create the temporary file with
754 </td>
755 </tr>
756 <tr>
757 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
758 <td> A file handle (as from <code class="function">open()</code>) to the file
759     opened for reading and writing. The file handle should be
760     closed with <code class="function">close()</code>. In case of errors, -1 is returned.
761
762 </td>
763 </tr>
764 </tbody>
765 </table></div>
766 <p class="since">Since 2.22</p>
767 </div>
768 <hr>
769 <div class="refsect2" title="g_file_open_tmp ()">
770 <a name="g-file-open-tmp"></a><h3>g_file_open_tmp ()</h3>
771 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_file_open_tmp                     (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *tmpl,
772                                                          <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> **name_used,
773                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
774 <p>
775 Opens a file for writing in the preferred directory for temporary
776 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>). 
777 </p>
778 <p>
779 <em class="parameter"><code>tmpl</code></em> should be a string in the GLib file name encoding containing 
780 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>.
781 However, unlike these functions, the template should only be a
782 basename, no directory components are allowed. If template is
783 <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, a default template is used.
784 </p>
785 <p>
786 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>) 
787 <em class="parameter"><code>tmpl</code></em> is not modified, and might thus be a read-only literal string.
788 </p>
789 <p>
790 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
791 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.
792 The returned name is in the GLib file name encoding.</p>
793 <div class="variablelist"><table border="0">
794 <col align="left" valign="top">
795 <tbody>
796 <tr>
797 <td><p><span class="term"><em class="parameter"><code>tmpl</code></em> :</span></p></td>
798 <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,
799        or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, to a default template
800 </td>
801 </tr>
802 <tr>
803 <td><p><span class="term"><em class="parameter"><code>name_used</code></em> :</span></p></td>
804 <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>
805 </td>
806 </tr>
807 <tr>
808 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
809 <td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
810 </td>
811 </tr>
812 <tr>
813 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
814 <td> A file handle (as from <code class="function">open()</code>) to 
815 the file opened for reading and writing. The file is opened in binary 
816 mode on platforms where there is a difference. The file handle should be
817 closed with <code class="function">close()</code>. In case of errors, -1 is returned 
818 and <em class="parameter"><code>error</code></em> will be set.
819 </td>
820 </tr>
821 </tbody>
822 </table></div>
823 </div>
824 <hr>
825 <div class="refsect2" title="g_file_read_link ()">
826 <a name="g-file-read-link"></a><h3>g_file_read_link ()</h3>
827 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *             g_file_read_link                    (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
828                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
829 <p>
830 Reads the contents of the symbolic link <em class="parameter"><code>filename</code></em> like the POSIX
831 <code class="function">readlink()</code> function.  The returned string is in the encoding used
832 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>
833 <div class="variablelist"><table border="0">
834 <col align="left" valign="top">
835 <tbody>
836 <tr>
837 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
838 <td> the symbolic link
839 </td>
840 </tr>
841 <tr>
842 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
843 <td> return location for a <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="type">GError</span></a>
844 </td>
845 </tr>
846 <tr>
847 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
848 <td> A newly-allocated string with the contents of the symbolic link, 
849          or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if an error occurred.
850
851 </td>
852 </tr>
853 </tbody>
854 </table></div>
855 <p class="since">Since 2.4</p>
856 </div>
857 <hr>
858 <div class="refsect2" title="g_mkdir_with_parents ()">
859 <a name="g-mkdir-with-parents"></a><h3>g_mkdir_with_parents ()</h3>
860 <pre class="programlisting"><span class="returnvalue">int</span>                 g_mkdir_with_parents                (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *pathname,
861                                                          <span class="returnvalue">int</span> mode);</pre>
862 <p>
863 Create a directory if it doesn't already exist. Create intermediate
864 parent directories as needed, too.</p>
865 <div class="variablelist"><table border="0">
866 <col align="left" valign="top">
867 <tbody>
868 <tr>
869 <td><p><span class="term"><em class="parameter"><code>pathname</code></em> :</span></p></td>
870 <td> a pathname in the GLib file name encoding
871 </td>
872 </tr>
873 <tr>
874 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
875 <td> permissions to use for newly created directories
876 </td>
877 </tr>
878 <tr>
879 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
880 <td> 0 if the directory already exists, or was successfully
881 created. Returns -1 if an error occurred, with errno set.
882
883 </td>
884 </tr>
885 </tbody>
886 </table></div>
887 <p class="since">Since 2.8</p>
888 </div>
889 <hr>
890 <div class="refsect2" title="GDir">
891 <a name="GDir"></a><h3>GDir</h3>
892 <pre class="programlisting">typedef struct _GDir GDir;</pre>
893 <p>
894 An opaque structure representing an opened directory.
895 </p>
896 </div>
897 <hr>
898 <div class="refsect2" title="g_dir_open ()">
899 <a name="g-dir-open"></a><h3>g_dir_open ()</h3>
900 <pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="returnvalue">GDir</span></a> *              g_dir_open                          (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *path,
901                                                          <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a> flags,
902                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
903 <p>
904 Opens a directory for reading. The names of the files in the
905 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>
906 <div class="variablelist"><table border="0">
907 <col align="left" valign="top">
908 <tbody>
909 <tr>
910 <td><p><span class="term"><em class="parameter"><code>path</code></em> :</span></p></td>
911 <td> the path to the directory you are interested in. On Unix
912         in the on-disk encoding. On Windows in UTF-8
913 </td>
914 </tr>
915 <tr>
916 <td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
917 <td> Currently must be set to 0. Reserved for future use.
918 </td>
919 </tr>
920 <tr>
921 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
922 <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>.
923         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
924         <a class="link" href="glib-File-Utilities.html#g-dir-open" title="g_dir_open ()"><code class="function">g_dir_open()</code></a> fails.
925 </td>
926 </tr>
927 <tr>
928 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
929 <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.
930   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>
931   when you are finished with it.
932 </td>
933 </tr>
934 </tbody>
935 </table></div>
936 </div>
937 <hr>
938 <div class="refsect2" title="g_dir_read_name ()">
939 <a name="g-dir-read-name"></a><h3>g_dir_read_name ()</h3>
940 <pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *       g_dir_read_name                     (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="returnvalue">GDir</span></a> *dir);</pre>
941 <p>
942 Retrieves the name of the next entry in the directory.  The '.' and
943 '..' entries are omitted. On Windows, the returned name is in
944 UTF-8. On Unix, it is in the on-disk encoding.</p>
945 <div class="variablelist"><table border="0">
946 <col align="left" valign="top">
947 <tbody>
948 <tr>
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>
951 </td>
952 </tr>
953 <tr>
954 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
955 <td> The entry's name or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if there are no 
956   more entries. The return value is owned by GLib and
957   must not be modified or freed.
958 </td>
959 </tr>
960 </tbody>
961 </table></div>
962 </div>
963 <hr>
964 <div class="refsect2" title="g_dir_rewind ()">
965 <a name="g-dir-rewind"></a><h3>g_dir_rewind ()</h3>
966 <pre class="programlisting"><span class="returnvalue">void</span>                g_dir_rewind                        (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="returnvalue">GDir</span></a> *dir);</pre>
967 <p>
968 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>
969 will return the first entry again.</p>
970 <div class="variablelist"><table border="0">
971 <col align="left" valign="top">
972 <tbody><tr>
973 <td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
974 <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>
975 </td>
976 </tr></tbody>
977 </table></div>
978 </div>
979 <hr>
980 <div class="refsect2" title="g_dir_close ()">
981 <a name="g-dir-close"></a><h3>g_dir_close ()</h3>
982 <pre class="programlisting"><span class="returnvalue">void</span>                g_dir_close                         (<a class="link" href="glib-File-Utilities.html#GDir" title="GDir"><span class="returnvalue">GDir</span></a> *dir);</pre>
983 <p>
984 Closes the directory and deallocates all related resources.</p>
985 <div class="variablelist"><table border="0">
986 <col align="left" valign="top">
987 <tbody><tr>
988 <td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td>
989 <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>
990 </td>
991 </tr></tbody>
992 </table></div>
993 </div>
994 <hr>
995 <div class="refsect2" title="GMappedFile">
996 <a name="GMappedFile"></a><h3>GMappedFile</h3>
997 <pre class="programlisting">typedef struct _GMappedFile GMappedFile;</pre>
998 <p>
999 The <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a> represents a file mapping created with
1000 <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
1001 not be accessed directly.
1002 </p>
1003 </div>
1004 <hr>
1005 <div class="refsect2" title="g_mapped_file_new ()">
1006 <a name="g-mapped-file-new"></a><h3>g_mapped_file_new ()</h3>
1007 <pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *       g_mapped_file_new                   (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1008                                                          <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a> writable,
1009                                                          <a class="link" href="glib-Error-Reporting.html#GError" title="GError"><span class="returnvalue">GError</span></a> **error);</pre>
1010 <p>
1011 Maps a file into memory. On UNIX, this is using the <code class="function">mmap()</code> function.
1012 </p>
1013 <p>
1014 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 it is an error to modify the mapped buffer. Modifications to the buffer 
1016 are not visible to other processes mapping the same file, and are not 
1017 written back to the file.
1018 </p>
1019 <p>
1020 Note that modifications of the underlying file might affect the contents
1021 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 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" title="g_file_set_contents ()"><code class="function">g_file_set_contents()</code></a>).</p>
1024 <div class="variablelist"><table border="0">
1025 <col align="left" valign="top">
1026 <tbody>
1027 <tr>
1028 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1029 <td> The path of the file to load, in the GLib filename encoding
1030 </td>
1031 </tr>
1032 <tr>
1033 <td><p><span class="term"><em class="parameter"><code>writable</code></em> :</span></p></td>
1034 <td> whether the mapping should be writable
1035 </td>
1036 </tr>
1037 <tr>
1038 <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
1039 <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>
1040 </td>
1041 </tr>
1042 <tr>
1043 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1044 <td> a newly allocated <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a> which must be unref'd
1045    with <a class="link" href="glib-File-Utilities.html#g-mapped-file-unref" title="g_mapped_file_unref ()"><code class="function">g_mapped_file_unref()</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.
1046
1047 </td>
1048 </tr>
1049 </tbody>
1050 </table></div>
1051 <p class="since">Since 2.8</p>
1052 </div>
1053 <hr>
1054 <div class="refsect2" title="g_mapped_file_ref ()">
1055 <a name="g-mapped-file-ref"></a><h3>g_mapped_file_ref ()</h3>
1056 <pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *       g_mapped_file_ref                   (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *file);</pre>
1057 <p>
1058 Increments the reference count of <em class="parameter"><code>file</code></em> by one.  It is safe to call
1059 this function from any thread.</p>
1060 <div class="variablelist"><table border="0">
1061 <col align="left" valign="top">
1062 <tbody>
1063 <tr>
1064 <td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1065 <td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1066 </td>
1067 </tr>
1068 <tr>
1069 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1070 <td> the passed in <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>.
1071
1072 </td>
1073 </tr>
1074 </tbody>
1075 </table></div>
1076 <p class="since">Since 2.22</p>
1077 </div>
1078 <hr>
1079 <div class="refsect2" title="g_mapped_file_unref ()">
1080 <a name="g-mapped-file-unref"></a><h3>g_mapped_file_unref ()</h3>
1081 <pre class="programlisting"><span class="returnvalue">void</span>                g_mapped_file_unref                 (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *file);</pre>
1082 <p>
1083 Decrements the reference count of <em class="parameter"><code>file</code></em> by one.  If the reference count
1084 drops to 0, unmaps the buffer of <em class="parameter"><code>file</code></em> and frees it.
1085 </p>
1086 <p>
1087 It is safe to call this function from any thread.
1088 </p>
1089 <p>
1090 Since 2.22</p>
1091 <div class="variablelist"><table border="0">
1092 <col align="left" valign="top">
1093 <tbody><tr>
1094 <td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1095 <td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1096 </td>
1097 </tr></tbody>
1098 </table></div>
1099 </div>
1100 <hr>
1101 <div class="refsect2" title="g_mapped_file_free ()">
1102 <a name="g-mapped-file-free"></a><h3>g_mapped_file_free ()</h3>
1103 <pre class="programlisting"><span class="returnvalue">void</span>                g_mapped_file_free                  (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *file);</pre>
1104 <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
1105 <h3 class="title">Warning</h3>
1106 <p><code class="literal">g_mapped_file_free</code> has been deprecated since version 2.22 and should not be used in newly-written code. Use <a class="link" href="glib-File-Utilities.html#g-mapped-file-unref" title="g_mapped_file_unref ()"><code class="function">g_mapped_file_unref()</code></a> instead.</p>
1107 </div>
1108 <p>
1109 This call existed before <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a> had refcounting and is currently
1110 exactly the same as <a class="link" href="glib-File-Utilities.html#g-mapped-file-unref" title="g_mapped_file_unref ()"><code class="function">g_mapped_file_unref()</code></a>.</p>
1111 <div class="variablelist"><table border="0">
1112 <col align="left" valign="top">
1113 <tbody><tr>
1114 <td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1115 <td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1116 </td>
1117 </tr></tbody>
1118 </table></div>
1119 <p class="since">Since 2.8</p>
1120 </div>
1121 <hr>
1122 <div class="refsect2" title="g_mapped_file_get_length ()">
1123 <a name="g-mapped-file-get-length"></a><h3>g_mapped_file_get_length ()</h3>
1124 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a>               g_mapped_file_get_length            (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *file);</pre>
1125 <p>
1126 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>
1127 <div class="variablelist"><table border="0">
1128 <col align="left" valign="top">
1129 <tbody>
1130 <tr>
1131 <td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1132 <td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1133 </td>
1134 </tr>
1135 <tr>
1136 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1137 <td> the length of the contents of <em class="parameter"><code>file</code></em>.
1138
1139 </td>
1140 </tr>
1141 </tbody>
1142 </table></div>
1143 <p class="since">Since 2.8</p>
1144 </div>
1145 <hr>
1146 <div class="refsect2" title="g_mapped_file_get_contents ()">
1147 <a name="g-mapped-file-get-contents"></a><h3>g_mapped_file_get_contents ()</h3>
1148 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *             g_mapped_file_get_contents          (<a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="returnvalue">GMappedFile</span></a> *file);</pre>
1149 <p>
1150 Returns the contents of a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>. 
1151 </p>
1152 <p>
1153 Note that the contents may not be zero-terminated,
1154 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.
1155 </p>
1156 <p>
1157 If the file is empty then <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.</p>
1158 <div class="variablelist"><table border="0">
1159 <col align="left" valign="top">
1160 <tbody>
1161 <tr>
1162 <td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td>
1163 <td> a <a class="link" href="glib-File-Utilities.html#GMappedFile" title="GMappedFile"><span class="type">GMappedFile</span></a>
1164 </td>
1165 </tr>
1166 <tr>
1167 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1168 <td> the contents of <em class="parameter"><code>file</code></em>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
1169
1170 </td>
1171 </tr>
1172 </tbody>
1173 </table></div>
1174 <p class="since">Since 2.8</p>
1175 </div>
1176 <hr>
1177 <div class="refsect2" title="g_open ()">
1178 <a name="g-open"></a><h3>g_open ()</h3>
1179 <pre class="programlisting"><span class="returnvalue">int</span>                 g_open                              (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1180                                                          <span class="returnvalue">int</span> flags,
1181                                                          <span class="returnvalue">int</span> mode);</pre>
1182 <p>
1183 A wrapper for the POSIX <code class="function">open()</code> function. The <code class="function">open()</code> function is
1184 used to convert a pathname into a file descriptor.
1185 </p>
1186 <p>
1187 On POSIX systems file descriptors are implemented by the operating
1188 system. On Windows, it's the C library that implements <code class="function">open()</code> and
1189 file descriptors. The actual Win32 API for opening files is quite
1190 different, see MSDN documentation for <code class="function">CreateFile()</code>. The Win32 API
1191 uses file handles, which are more randomish integers, not small
1192 integers like file descriptors.
1193 </p>
1194 <p>
1195 Because file descriptors are specific to the C library on Windows,
1196 the file descriptor returned by this function makes sense only to
1197 functions in the same C library. Thus if the GLib-using code uses a
1198 different C library than GLib does, the file descriptor returned by
1199 this function cannot be passed to C library functions like <code class="function">write()</code>
1200 or <code class="function">read()</code>.
1201 </p>
1202 <p>
1203 See your C library manual for more details about <code class="function">open()</code>.</p>
1204 <div class="variablelist"><table border="0">
1205 <col align="left" valign="top">
1206 <tbody>
1207 <tr>
1208 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1209 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1210 </td>
1211 </tr>
1212 <tr>
1213 <td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td>
1214 <td> as in <code class="function">open()</code>
1215 </td>
1216 </tr>
1217 <tr>
1218 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1219 <td> as in <code class="function">open()</code>
1220 </td>
1221 </tr>
1222 <tr>
1223 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1224 <td> a new file descriptor, or -1 if an error occurred. The
1225 return value can be used exactly like the return value from <code class="function">open()</code>.
1226
1227 </td>
1228 </tr>
1229 </tbody>
1230 </table></div>
1231 <p class="since">Since 2.6</p>
1232 </div>
1233 <hr>
1234 <div class="refsect2" title="g_rename ()">
1235 <a name="g-rename"></a><h3>g_rename ()</h3>
1236 <pre class="programlisting"><span class="returnvalue">int</span>                 g_rename                            (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *oldfilename,
1237                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *newfilename);</pre>
1238 <p>
1239 A wrapper for the POSIX <code class="function">rename()</code> function. The <code class="function">rename()</code> function 
1240 renames a file, moving it between directories if required.
1241 </p>
1242 <p>
1243 See your C library manual for more details about how <code class="function">rename()</code> works
1244 on your system. It is not possible in general on Windows to rename
1245 a file that is open to some process.</p>
1246 <div class="variablelist"><table border="0">
1247 <col align="left" valign="top">
1248 <tbody>
1249 <tr>
1250 <td><p><span class="term"><em class="parameter"><code>oldfilename</code></em> :</span></p></td>
1251 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1252 </td>
1253 </tr>
1254 <tr>
1255 <td><p><span class="term"><em class="parameter"><code>newfilename</code></em> :</span></p></td>
1256 <td> a pathname in the GLib file name encoding
1257 </td>
1258 </tr>
1259 <tr>
1260 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1261 <td> 0 if the renaming succeeded, -1 if an error occurred
1262
1263 </td>
1264 </tr>
1265 </tbody>
1266 </table></div>
1267 <p class="since">Since 2.6</p>
1268 </div>
1269 <hr>
1270 <div class="refsect2" title="g_mkdir ()">
1271 <a name="g-mkdir"></a><h3>g_mkdir ()</h3>
1272 <pre class="programlisting"><span class="returnvalue">int</span>                 g_mkdir                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1273                                                          <span class="returnvalue">int</span> mode);</pre>
1274 <p>
1275 A wrapper for the POSIX <code class="function">mkdir()</code> function. The <code class="function">mkdir()</code> function 
1276 attempts to create a directory with the given name and permissions.
1277 The mode argument is ignored on Windows.
1278 </p>
1279 <p>
1280 See your C library manual for more details about <code class="function">mkdir()</code>.</p>
1281 <div class="variablelist"><table border="0">
1282 <col align="left" valign="top">
1283 <tbody>
1284 <tr>
1285 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1286 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1287 </td>
1288 </tr>
1289 <tr>
1290 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1291 <td> permissions to use for the newly created directory
1292 </td>
1293 </tr>
1294 <tr>
1295 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1296 <td> 0 if the directory was successfully created, -1 if an error 
1297    occurred
1298
1299 </td>
1300 </tr>
1301 </tbody>
1302 </table></div>
1303 <p class="since">Since 2.6</p>
1304 </div>
1305 <hr>
1306 <div class="refsect2" title="g_stat ()">
1307 <a name="g-stat"></a><h3>g_stat ()</h3>
1308 <pre class="programlisting"><span class="returnvalue">int</span>                 g_stat                              (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1309                                                          <span class="returnvalue">struct _g_stat_struct</span> *buf);</pre>
1310 <p>
1311 A wrapper for the POSIX <code class="function">stat()</code> function. The <code class="function">stat()</code> function
1312 returns information about a file. On Windows the <code class="function">stat()</code> function in
1313 the C library checks only the FAT-style READONLY attribute and does
1314 not look at the ACL at all. Thus on Windows the protection bits in
1315 the st_mode field are a fabrication of little use.
1316 </p>
1317 <p>
1318 See your C library manual for more details about <code class="function">stat()</code>.</p>
1319 <div class="variablelist"><table border="0">
1320 <col align="left" valign="top">
1321 <tbody>
1322 <tr>
1323 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1324 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1325 </td>
1326 </tr>
1327 <tr>
1328 <td><p><span class="term"><em class="parameter"><code>buf</code></em> :</span></p></td>
1329 <td> a pointer to a <span class="structname">stat</span> struct, which
1330    will be filled with the file information
1331 </td>
1332 </tr>
1333 <tr>
1334 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1335 <td> 0 if the information was successfully retrieved, -1 if an error 
1336    occurred
1337
1338 </td>
1339 </tr>
1340 </tbody>
1341 </table></div>
1342 <p class="since">Since 2.6</p>
1343 </div>
1344 <hr>
1345 <div class="refsect2" title="g_lstat ()">
1346 <a name="g-lstat"></a><h3>g_lstat ()</h3>
1347 <pre class="programlisting"><span class="returnvalue">int</span>                 g_lstat                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1348                                                          <span class="returnvalue">struct _g_stat_struct</span> *buf);</pre>
1349 <p>
1350 A wrapper for the POSIX <code class="function">lstat()</code> function. The <code class="function">lstat()</code> function is
1351 like <code class="function">stat()</code> except that in the case of symbolic links, it returns
1352 information about the symbolic link itself and not the file that it
1353 refers to. If the system does not support symbolic links <a class="link" href="glib-File-Utilities.html#g-lstat" title="g_lstat ()"><code class="function">g_lstat()</code></a>
1354 is identical to <a class="link" href="glib-File-Utilities.html#g-stat" title="g_stat ()"><code class="function">g_stat()</code></a>.
1355 </p>
1356 <p>
1357 See your C library manual for more details about <code class="function">lstat()</code>.</p>
1358 <div class="variablelist"><table border="0">
1359 <col align="left" valign="top">
1360 <tbody>
1361 <tr>
1362 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1363 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1364 </td>
1365 </tr>
1366 <tr>
1367 <td><p><span class="term"><em class="parameter"><code>buf</code></em> :</span></p></td>
1368 <td> a pointer to a <span class="structname">stat</span> struct, which
1369    will be filled with the file information
1370 </td>
1371 </tr>
1372 <tr>
1373 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1374 <td> 0 if the information was successfully retrieved, -1 if an error 
1375    occurred
1376
1377 </td>
1378 </tr>
1379 </tbody>
1380 </table></div>
1381 <p class="since">Since 2.6</p>
1382 </div>
1383 <hr>
1384 <div class="refsect2" title="g_unlink ()">
1385 <a name="g-unlink"></a><h3>g_unlink ()</h3>
1386 <pre class="programlisting"><span class="returnvalue">int</span>                 g_unlink                            (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename);</pre>
1387 <p>
1388 A wrapper for the POSIX <code class="function">unlink()</code> function. The <code class="function">unlink()</code> function 
1389 deletes a name from the filesystem. If this was the last link to the 
1390 file and no processes have it opened, the diskspace occupied by the
1391 file is freed.
1392 </p>
1393 <p>
1394 See your C library manual for more details about <code class="function">unlink()</code>. Note
1395 that on Windows, it is in general not possible to delete files that
1396 are open to some process, or mapped into memory.</p>
1397 <div class="variablelist"><table border="0">
1398 <col align="left" valign="top">
1399 <tbody>
1400 <tr>
1401 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1402 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1403 </td>
1404 </tr>
1405 <tr>
1406 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1407 <td> 0 if the name was successfully deleted, -1 if an error 
1408    occurred
1409
1410 </td>
1411 </tr>
1412 </tbody>
1413 </table></div>
1414 <p class="since">Since 2.6</p>
1415 </div>
1416 <hr>
1417 <div class="refsect2" title="g_remove ()">
1418 <a name="g-remove"></a><h3>g_remove ()</h3>
1419 <pre class="programlisting"><span class="returnvalue">int</span>                 g_remove                            (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename);</pre>
1420 <p>
1421 A wrapper for the POSIX <code class="function">remove()</code> function. The <code class="function">remove()</code> function
1422 deletes a name from the filesystem.
1423 </p>
1424 <p>
1425 See your C library manual for more details about how <code class="function">remove()</code> works
1426 on your system. On Unix, <code class="function">remove()</code> removes also directories, as it
1427 calls <code class="function">unlink()</code> for files and <code class="function">rmdir()</code> for directories. On Windows,
1428 although <code class="function">remove()</code> in the C library only works for files, this
1429 function tries first <code class="function">remove()</code> and then if that fails <code class="function">rmdir()</code>, and
1430 thus works for both files and directories. Note however, that on
1431 Windows, it is in general not possible to remove a file that is
1432 open to some process, or mapped into memory.
1433 </p>
1434 <p>
1435 If this function fails on Windows you can't infer too much from the
1436 errno value. <code class="function">rmdir()</code> is tried regardless of what caused <code class="function">remove()</code> to
1437 fail. Any errno value set by <code class="function">remove()</code> will be overwritten by that
1438 set by <code class="function">rmdir()</code>.</p>
1439 <div class="variablelist"><table border="0">
1440 <col align="left" valign="top">
1441 <tbody>
1442 <tr>
1443 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1444 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1445 </td>
1446 </tr>
1447 <tr>
1448 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1449 <td> 0 if the file was successfully removed, -1 if an error 
1450    occurred
1451
1452 </td>
1453 </tr>
1454 </tbody>
1455 </table></div>
1456 <p class="since">Since 2.6</p>
1457 </div>
1458 <hr>
1459 <div class="refsect2" title="g_rmdir ()">
1460 <a name="g-rmdir"></a><h3>g_rmdir ()</h3>
1461 <pre class="programlisting"><span class="returnvalue">int</span>                 g_rmdir                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename);</pre>
1462 <p>
1463 A wrapper for the POSIX <code class="function">rmdir()</code> function. The <code class="function">rmdir()</code> function
1464 deletes a directory from the filesystem.
1465 </p>
1466 <p>
1467 See your C library manual for more details about how <code class="function">rmdir()</code> works
1468 on your system.</p>
1469 <div class="variablelist"><table border="0">
1470 <col align="left" valign="top">
1471 <tbody>
1472 <tr>
1473 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1474 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1475 </td>
1476 </tr>
1477 <tr>
1478 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1479 <td> 0 if the directory was successfully removed, -1 if an error 
1480    occurred
1481
1482 </td>
1483 </tr>
1484 </tbody>
1485 </table></div>
1486 <p class="since">Since 2.6</p>
1487 </div>
1488 <hr>
1489 <div class="refsect2" title="g_fopen ()">
1490 <a name="g-fopen"></a><h3>g_fopen ()</h3>
1491 <pre class="programlisting"><span class="returnvalue">FILE</span> *              g_fopen                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1492                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *mode);</pre>
1493 <p>
1494 A wrapper for the stdio <code class="function">fopen()</code> function. The <code class="function">fopen()</code> function
1495 opens a file and associates a new stream with it.
1496 </p>
1497 <p>
1498 Because file descriptors are specific to the C library on Windows,
1499 and a file descriptor is partof the <span class="type">FILE</span> struct, the
1500 <span class="type">FILE</span> pointer returned by this function makes sense
1501 only to functions in the same C library. Thus if the GLib-using
1502 code uses a different C library than GLib does, the
1503 <span class="type">FILE</span> pointer returned by this function cannot be
1504 passed to C library functions like <code class="function">fprintf()</code> or <code class="function">fread()</code>.
1505 </p>
1506 <p>
1507 See your C library manual for more details about <code class="function">fopen()</code>.</p>
1508 <div class="variablelist"><table border="0">
1509 <col align="left" valign="top">
1510 <tbody>
1511 <tr>
1512 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1513 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1514 </td>
1515 </tr>
1516 <tr>
1517 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1518 <td> a string describing the mode in which the file should be 
1519   opened
1520 </td>
1521 </tr>
1522 <tr>
1523 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1524 <td> A <span class="type">FILE</span> pointer if the file was successfully
1525    opened, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if an error occurred
1526
1527 </td>
1528 </tr>
1529 </tbody>
1530 </table></div>
1531 <p class="since">Since 2.6</p>
1532 </div>
1533 <hr>
1534 <div class="refsect2" title="g_freopen ()">
1535 <a name="g-freopen"></a><h3>g_freopen ()</h3>
1536 <pre class="programlisting"><span class="returnvalue">FILE</span> *              g_freopen                           (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1537                                                          const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *mode,
1538                                                          <span class="returnvalue">FILE</span> *stream);</pre>
1539 <p>
1540 A wrapper for the POSIX <code class="function">freopen()</code> function. The <code class="function">freopen()</code> function
1541 opens a file and associates it with an existing stream.
1542 </p>
1543 <p>
1544 See your C library manual for more details about <code class="function">freopen()</code>.</p>
1545 <div class="variablelist"><table border="0">
1546 <col align="left" valign="top">
1547 <tbody>
1548 <tr>
1549 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1550 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1551 </td>
1552 </tr>
1553 <tr>
1554 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1555 <td> a string describing the mode in which the file should be 
1556   opened
1557 </td>
1558 </tr>
1559 <tr>
1560 <td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
1561 <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>
1562 </td>
1563 </tr>
1564 <tr>
1565 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1566 <td> A <span class="type">FILE</span> pointer if the file was successfully
1567    opened, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if an error occurred.
1568
1569 </td>
1570 </tr>
1571 </tbody>
1572 </table></div>
1573 <p class="since">Since 2.6</p>
1574 </div>
1575 <hr>
1576 <div class="refsect2" title="g_chmod ()">
1577 <a name="g-chmod"></a><h3>g_chmod ()</h3>
1578 <pre class="programlisting"><span class="returnvalue">int</span>                 g_chmod                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1579                                                          <span class="returnvalue">int</span> mode);</pre>
1580 <p>
1581 A wrapper for the POSIX <code class="function">chmod()</code> function. The <code class="function">chmod()</code> function is
1582 used to set the permissions of a file system object.
1583 </p>
1584 <p>
1585 On Windows the file protection mechanism is not at all POSIX-like,
1586 and the underlying <code class="function">chmod()</code> function in the C library just sets or
1587 clears the FAT-style READONLY attribute. It does not touch any
1588 ACL. Software that needs to manage file permissions on Windows
1589 exactly should use the Win32 API.
1590 </p>
1591 <p>
1592 See your C library manual for more details about <code class="function">chmod()</code>.</p>
1593 <div class="variablelist"><table border="0">
1594 <col align="left" valign="top">
1595 <tbody>
1596 <tr>
1597 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1598 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1599 </td>
1600 </tr>
1601 <tr>
1602 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1603 <td> as in <code class="function">chmod()</code>
1604 </td>
1605 </tr>
1606 <tr>
1607 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1608 <td> zero if the operation succeeded, -1 on error.
1609
1610 </td>
1611 </tr>
1612 </tbody>
1613 </table></div>
1614 <p class="since">Since 2.8</p>
1615 </div>
1616 <hr>
1617 <div class="refsect2" title="g_access ()">
1618 <a name="g-access"></a><h3>g_access ()</h3>
1619 <pre class="programlisting"><span class="returnvalue">int</span>                 g_access                            (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1620                                                          <span class="returnvalue">int</span> mode);</pre>
1621 <p>
1622 A wrapper for the POSIX <code class="function">access()</code> function. This function is used to
1623 test a pathname for one or several of read, write or execute
1624 permissions, or just existence.
1625 </p>
1626 <p>
1627 On Windows, the file protection mechanism is not at all POSIX-like,
1628 and the underlying function in the C library only checks the
1629 FAT-style READONLY attribute, and does not look at the ACL of a
1630 file at all. This function is this in practise almost useless on
1631 Windows. Software that needs to handle file permissions on Windows
1632 more exactly should use the Win32 API.
1633 </p>
1634 <p>
1635 See your C library manual for more details about <code class="function">access()</code>.</p>
1636 <div class="variablelist"><table border="0">
1637 <col align="left" valign="top">
1638 <tbody>
1639 <tr>
1640 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1641 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1642 </td>
1643 </tr>
1644 <tr>
1645 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1646 <td> as in <code class="function">access()</code>
1647 </td>
1648 </tr>
1649 <tr>
1650 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1651 <td> zero if the pathname refers to an existing file system
1652 object that has all the tested permissions, or -1 otherwise or on
1653 error.
1654
1655 </td>
1656 </tr>
1657 </tbody>
1658 </table></div>
1659 <p class="since">Since 2.8</p>
1660 </div>
1661 <hr>
1662 <div class="refsect2" title="g_creat ()">
1663 <a name="g-creat"></a><h3>g_creat ()</h3>
1664 <pre class="programlisting"><span class="returnvalue">int</span>                 g_creat                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1665                                                          <span class="returnvalue">int</span> mode);</pre>
1666 <p>
1667 A wrapper for the POSIX <code class="function">creat()</code> function. The <code class="function">creat()</code> function is
1668 used to convert a pathname into a file descriptor, creating a file
1669 if necessary.
1670 </p>
1671 <p>
1672 On POSIX systems file descriptors are implemented by the operating
1673 system. On Windows, it's the C library that implements <code class="function">creat()</code> and
1674 file descriptors. The actual Windows API for opening files is
1675 different, see MSDN documentation for <code class="function">CreateFile()</code>. The Win32 API
1676 uses file handles, which are more randomish integers, not small
1677 integers like file descriptors.
1678 </p>
1679 <p>
1680 Because file descriptors are specific to the C library on Windows,
1681 the file descriptor returned by this function makes sense only to
1682 functions in the same C library. Thus if the GLib-using code uses a
1683 different C library than GLib does, the file descriptor returned by
1684 this function cannot be passed to C library functions like <code class="function">write()</code>
1685 or <code class="function">read()</code>.
1686 </p>
1687 <p>
1688 See your C library manual for more details about <code class="function">creat()</code>.</p>
1689 <div class="variablelist"><table border="0">
1690 <col align="left" valign="top">
1691 <tbody>
1692 <tr>
1693 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1694 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1695 </td>
1696 </tr>
1697 <tr>
1698 <td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td>
1699 <td> as in <code class="function">creat()</code>
1700 </td>
1701 </tr>
1702 <tr>
1703 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1704 <td> a new file descriptor, or -1 if an error occurred. The
1705 return value can be used exactly like the return value from <code class="function">creat()</code>.
1706
1707 </td>
1708 </tr>
1709 </tbody>
1710 </table></div>
1711 <p class="since">Since 2.8</p>
1712 </div>
1713 <hr>
1714 <div class="refsect2" title="g_chdir ()">
1715 <a name="g-chdir"></a><h3>g_chdir ()</h3>
1716 <pre class="programlisting"><span class="returnvalue">int</span>                 g_chdir                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *path);</pre>
1717 <p>
1718 A wrapper for the POSIX <code class="function">chdir()</code> function. The function changes the
1719 current directory of the process to <em class="parameter"><code>path</code></em>.
1720 </p>
1721 <p>
1722 See your C library manual for more details about <code class="function">chdir()</code>.</p>
1723 <div class="variablelist"><table border="0">
1724 <col align="left" valign="top">
1725 <tbody>
1726 <tr>
1727 <td><p><span class="term"><em class="parameter"><code>path</code></em> :</span></p></td>
1728 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1729 </td>
1730 </tr>
1731 <tr>
1732 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1733 <td> 0 on success, -1 if an error occurred.
1734
1735 </td>
1736 </tr>
1737 </tbody>
1738 </table></div>
1739 <p class="since">Since 2.8</p>
1740 </div>
1741 <hr>
1742 <div class="refsect2" title="g_utime ()">
1743 <a name="g-utime"></a><h3>g_utime ()</h3>
1744 <pre class="programlisting"><span class="returnvalue">int</span>                 g_utime                             (const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *filename,
1745                                                          <span class="returnvalue">struct utimbuf</span> *utb);</pre>
1746 <p>
1747 A wrapper for the POSIX <code class="function">utime()</code> function. The <code class="function">utime()</code> function
1748 sets the access and modification timestamps of a file.
1749 </p>
1750 <p>
1751 See your C library manual for more details about how <code class="function">utime()</code> works
1752 on your system.</p>
1753 <div class="variablelist"><table border="0">
1754 <col align="left" valign="top">
1755 <tbody>
1756 <tr>
1757 <td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td>
1758 <td> a pathname in the GLib file name encoding (UTF-8 on Windows)
1759 </td>
1760 </tr>
1761 <tr>
1762 <td><p><span class="term"><em class="parameter"><code>utb</code></em> :</span></p></td>
1763 <td> a pointer to a struct utimbuf.
1764 </td>
1765 </tr>
1766 <tr>
1767 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1768 <td> 0 if the operation was successful, -1 if an error 
1769    occurred
1770
1771 </td>
1772 </tr>
1773 </tbody>
1774 </table></div>
1775 <p class="since">Since 2.18</p>
1776 </div>
1777 </div>
1778 </div>
1779 <div class="footer">
1780 <hr>
1781           Generated by GTK-Doc V1.13</div>
1782 </body>
1783 </html>