📄 glib-file-utilities.html
字号:
<td> The entry's name or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if there are no more entries. The return value is owned by GLib and must not be modified or freed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3111726"></a><h3><a name="g-dir-rewind"></a>g_dir_rewind ()</h3><a class="indexterm" name="id3111739"></a><pre class="programlisting">void g_dir_rewind (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);</pre><p>Resets the given directory. The next call to <a class="link" href="glib-File-Utilities.html#g-dir-read-name"><code class="function">g_dir_read_name()</code></a>will return the first entry again.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td><td> a <a class="link" href="glib-File-Utilities.html#GDir"><span class="type">GDir</span></a>* created by <a class="link" href="glib-File-Utilities.html#g-dir-open"><code class="function">g_dir_open()</code></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3111818"></a><h3><a name="g-dir-close"></a>g_dir_close ()</h3><a class="indexterm" name="id3111831"></a><pre class="programlisting">void g_dir_close (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);</pre><p>Closes the directory and deallocates all related resources.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>dir</code></em> :</span></p></td><td> a <a class="link" href="glib-File-Utilities.html#GDir"><span class="type">GDir</span></a>* created by <a class="link" href="glib-File-Utilities.html#g-dir-open"><code class="function">g_dir_open()</code></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3111899"></a><h3><a name="GMappedFile"></a>GMappedFile</h3><a class="indexterm" name="id3111911"></a><pre class="programlisting">typedef struct _GMappedFile GMappedFile;</pre><p>The <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a> represents a file mapping created with<a class="link" href="glib-File-Utilities.html#g-mapped-file-new"><code class="function">g_mapped_file_new()</code></a>. It has only private members and shouldnot be accessed directly.</p></div><hr><div class="refsect2" lang="en"><a name="id3111947"></a><h3><a name="g-mapped-file-new"></a>g_mapped_file_new ()</h3><a class="indexterm" name="id3111963"></a><pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a>* g_mapped_file_new (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename, <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> writable, <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Maps a file into memory. On UNIX, this is using the <code class="function">mmap()</code> function.</p><p>If <em class="parameter"><code>writable</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, the mapped buffer may be modified, otherwiseit is an error to modify the mapped buffer. Modifications to the buffer are not visible to other processes mapping the same file, and are not written back to the file.</p><p>Note that modifications of the underlying file might affect the contentsof the <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>. Therefore, mapping should only be used if the file will not be modified, or if all modifications of the file are doneatomically (e.g. using <a class="link" href="glib-File-Utilities.html#g-file-set-contents"><code class="function">g_file_set_contents()</code></a>).</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td><td> The path of the file to load, in the GLib filename encoding</td></tr><tr><td><p><span class="term"><em class="parameter"><code>writable</code></em> :</span></p></td><td> whether the mapping should be writable</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td><td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a newly allocated <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a> which must be freed with <a class="link" href="glib-File-Utilities.html#g-mapped-file-free"><code class="function">g_mapped_file_free()</code></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the mapping failed. </td></tr></tbody></table></div><p class="since">Since 2.8</p></div><hr><div class="refsect2" lang="en"><a name="id3112183"></a><h3><a name="g-mapped-file-free"></a>g_mapped_file_free ()</h3><a class="indexterm" name="id3112198"></a><pre class="programlisting">void g_mapped_file_free (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);</pre><p>Unmaps the buffer of <em class="parameter"><code>file</code></em> and frees it.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td><td> a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a></td></tr></tbody></table></div><p class="since">Since 2.8</p></div><hr><div class="refsect2" lang="en"><a name="id3112268"></a><h3><a name="g-mapped-file-get-length"></a>g_mapped_file_get_length ()</h3><a class="indexterm" name="id3112284"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gsize">gsize</a> g_mapped_file_get_length (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);</pre><p>Returns the length of the contents of a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td><td> a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the length of the contents of <em class="parameter"><code>file</code></em>.</td></tr></tbody></table></div><p class="since">Since 2.8</p></div><hr><div class="refsect2" lang="en"><a name="id3112373"></a><h3><a name="g-mapped-file-get-contents"></a>g_mapped_file_get_contents ()</h3><a class="indexterm" name="id3112389"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>* g_mapped_file_get_contents (<a class="link" href="glib-File-Utilities.html#GMappedFile">GMappedFile</a> *file);</pre><p>Returns the contents of a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a>. </p><p>Note that the contents may not be zero-terminated,even if the <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a> is backed by a text file.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>file</code></em> :</span></p></td><td> a <a class="link" href="glib-File-Utilities.html#GMappedFile"><span class="type">GMappedFile</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the contents of <em class="parameter"><code>file</code></em>.</td></tr></tbody></table></div><p class="since">Since 2.8</p></div><hr><div class="refsect2" lang="en"><a name="id3112490"></a><h3><a name="g-open"></a>g_open ()</h3><a class="indexterm" name="id3112504"></a><pre class="programlisting">int g_open (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename, int flags, int mode);</pre><p>A wrapper for the POSIX <code class="function">open()</code> function. The <code class="function">open()</code> function isused to convert a pathname into a file descriptor. Note that onPOSIX systems file descriptors are implemented by the operatingsystem. On Windows, it's the C library that implements <code class="function">open()</code> andfile descriptors. The actual Windows API for opening files issomething different.</p><p>See the C library manual for more details about <code class="function">open()</code>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td><td> a pathname in the GLib file name encoding (UTF-8 on Windows)</td></tr><tr><td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td><td> as in <code class="function">open()</code></td></tr><tr><td><p><span class="term"><em class="parameter"><code>mode</code></em> :</span></p></td><td> as in <code class="function">open()</code></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a new file descriptor, or -1 if an error occurred. Th
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -