⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-file-utilities.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
template. The X string will be modified to form the name of a file that didn't exist.The string should be in the GLib file name encoding. Most importantly, on Windows it should be in UTF-8.</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>tmpl</code></em>&#160;:</span></p></td><td> template filename</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> A file handle (as from <code class="function">open()</code>) to the fileopened for reading and writing. The file is opened in binary modeon platforms where there is a difference. The file handle should beclosed with <code class="function">close()</code>. In case of errors, -1 is returned.  </td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3110862"></a><h3><a name="g-file-open-tmp"></a>g_file_open_tmp ()</h3><a class="indexterm" name="id3110872"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a>                g_file_open_tmp                     (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *tmpl,                                                         <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> **name_used,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Opens a file for writing in the preferred directory for temporaryfiles (as returned by <a class="link" href="glib-Miscellaneous-Utility-Functions.html#g-get-tmp-dir"><code class="function">g_get_tmp_dir()</code></a>). </p><p><em class="parameter"><code>tmpl</code></em> should be a string in the GLib file name encoding containing a sequence of six 'X' characters, as the parameter to <a class="link" href="glib-File-Utilities.html#g-mkstemp"><code class="function">g_mkstemp()</code></a>.However, unlike these functions, the template should only be abasename, no directory components are allowed. If template is<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, a default template is used.</p><p>Note that in contrast to <a class="link" href="glib-File-Utilities.html#g-mkstemp"><code class="function">g_mkstemp()</code></a> (and <code class="function">mkstemp()</code>) <em class="parameter"><code>tmpl</code></em> is not modified, and might thus be a read-only literal string.</p><p>The actual name used is returned in <em class="parameter"><code>name_used</code></em> if non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. Thisstring should be freed with <a class="link" href="glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> when not needed any longer.The returned name is in the GLib file name encoding.</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>tmpl</code></em>&#160;:</span></p></td><td> Template for file name, as in <a class="link" href="glib-File-Utilities.html#g-mkstemp"><code class="function">g_mkstemp()</code></a>, basename only,       or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, to a default template</td></tr><tr><td><p><span class="term"><em class="parameter"><code>name_used</code></em>&#160;:</span></p></td><td> location to store actual name used</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> A file handle (as from <code class="function">open()</code>) to the file opened for reading and writing. The file is opened in binary mode on platforms where there is a difference. The file handle should beclosed with <code class="function">close()</code>. In case of errors, -1 is returned and <em class="parameter"><code>error</code></em> will be set.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3111119"></a><h3><a name="g-file-read-link"></a>g_file_read_link ()</h3><a class="indexterm" name="id3111134"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              g_file_read_link                    (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *filename,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Reads the contents of the symbolic link <em class="parameter"><code>filename</code></em> like the POSIX<code class="function">readlink()</code> function.  The returned string is in the encoding usedfor filenames. Use <a class="link" href="glib-Character-Set-Conversion.html#g-filename-to-utf8"><code class="function">g_filename_to_utf8()</code></a> to convert it to UTF-8.</p><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>&#160;:</span></p></td><td> the symbolic link</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td> return location for a <a class="link" href="glib-Error-Reporting.html#GError"><span class="type">GError</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> A newly allocated string with the contents of the symbolic link,          or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if an error occurred.</td></tr></tbody></table></div><p class="since">Since  2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3111272"></a><h3><a name="g-mkdir-with-parents"></a>g_mkdir_with_parents ()</h3><a class="indexterm" name="id3111288"></a><pre class="programlisting">int                 g_mkdir_with_parents                (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *pathname,                                                         int mode);</pre><p>Create a directory if it doesn't already exist. Create intermediateparent directories as needed, too.</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>pathname</code></em>&#160;:</span></p></td><td> a pathname in the GLib file name encoding</td></tr><tr><td><p><span class="term"><em class="parameter"><code>mode</code></em>&#160;:</span></p></td><td> permissions to use for newly created directories</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> 0 if the directory already exists, or was successfullycreated. Returns -1 if an error occurred, with errno set.</td></tr></tbody></table></div><p class="since">Since  2.8</p></div><hr><div class="refsect2" lang="en"><a name="id3111380"></a><h3><a name="GDir"></a>GDir</h3><a class="indexterm" name="id3111392"></a><pre class="programlisting">typedef struct _GDir GDir;</pre><p>An opaque structure representing an opened directory.</p></div><hr><div class="refsect2" lang="en"><a name="id3111409"></a><h3><a name="g-dir-open"></a>g_dir_open ()</h3><a class="indexterm" name="id3111421"></a><pre class="programlisting"><a class="link" href="glib-File-Utilities.html#GDir">GDir</a>*               g_dir_open                          (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *path,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> flags,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Opens a directory for reading. The names of the files in thedirectory can then be retrieved using <a class="link" href="glib-File-Utilities.html#g-dir-read-name"><code class="function">g_dir_read_name()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>path</code></em>&#160;:</span></p></td><td> the path to the directory you are interested in. On Unix        in the on-disk encoding. On Windows in UTF-8</td></tr><tr><td><p><span class="term"><em class="parameter"><code>flags</code></em>&#160;:</span></p></td><td> Currently must be set to 0. Reserved for future use.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</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>.        If non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, an error will be set if and only if        <a class="link" href="glib-File-Utilities.html#g-dir-open"><code class="function">g_dir_open()</code></a> fails.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> a newly allocated <a class="link" href="glib-File-Utilities.html#GDir"><span class="type">GDir</span></a> on success, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on failure.  If non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, you must free the result with <a class="link" href="glib-File-Utilities.html#g-dir-close"><code class="function">g_dir_close()</code></a>  when you are finished with it.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3111619"></a><h3><a name="g-dir-read-name"></a>g_dir_read_name ()</h3><a class="indexterm" name="id3111632"></a><pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*        g_dir_read_name                     (<a class="link" href="glib-File-Utilities.html#GDir">GDir</a> *dir);</pre><p>Retrieves the name of the next entry in the directory.  The '.' and'..' entries are omitted. On Windows, the returned name is inUTF-8. On Unix, it is in the on-disk encoding.</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>&#160;:</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><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -