📄 glib-miscellaneous-utility-functions.html
字号:
Removes an environment variable from the environment.</p><p>Note that on some systems, when variables are overwritten, the memory used for the previous variables and its value isn't reclaimed.Furthermore, this function can't be guaranteed to operate in a threadsafe way.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>variable</code></em> :</span></td><td> the environment variable to remove, must not contain '='.</td></tr></tbody></table></div><p>Since 2.4 </p></div><hr><div class="refsect2" lang="en"><a name="id3021450"></a><h3><a name="g-get-user-name"></a>g_get_user_name ()</h3><a class="indexterm" name="id3021461"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_user_name (void);</pre><p>Gets the user name of the current user. The encoding of the returnedstring is system defined. On Unix, it might be the preferred file nameencoding, or something else, and there is no guarantee that it is evenconsistent on a machine. On Windows, it is always UTF-8.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the user name of the current user.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3021504"></a><h3><a name="g-get-real-name"></a>g_get_real_name ()</h3><a class="indexterm" name="id3021514"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_real_name (void);</pre><p>Gets the real name of the user. This usually comes from the user's entry in the<code class="filename">passwd</code> file. The encoding of the returned string is systemdefined. (On Windows, it is, however, always UTF-8.) If the real user namecannot be determined, the string "Unknown" is returned.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the user's real name.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3021562"></a><h3><a name="g-get-user-cache-dir"></a>g_get_user_cache_dir ()</h3><a class="indexterm" name="id3021573"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_user_cache_dir (void);</pre><p>Returns a base directory in which to store non-essential, cacheddata specific to particular user.</p><p>On Unix platforms this is determined using the mechanisms described inthe <a href="http://www.freedesktop.org/Standards/basedir-spec" target="_top">XDG Base Directory Specification</a></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a string owned by GLib that must not be modified or freed.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3021631"></a><h3><a name="g-get-user-data-dir"></a>g_get_user_data_dir ()</h3><a class="indexterm" name="id3021643"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_user_data_dir (void);</pre><p>Returns a base directory in which to access application data suchas icons that is customized for a particular user. </p><p>On Unix platforms this is determined using the mechanisms described inthe <a href="http://www.freedesktop.org/Standards/basedir-spec" target="_top">XDG Base Directory Specification</a></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a string owned by GLib that must not be modified or freed.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3021701"></a><h3><a name="g-get-user-config-dir"></a>g_get_user_config_dir ()</h3><a class="indexterm" name="id3021712"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_user_config_dir (void);</pre><p>Returns a base directory in which to store user-specific application configuration information such as user preferences and settings. </p><p>On Unix platforms this is determined using the mechanisms described inthe <a href="http://www.freedesktop.org/Standards/basedir-spec" target="_top">XDG Base Directory Specification</a></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a string owned by GLib that must not be modified or freed.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3021770"></a><h3><a name="g-get-system-data-dirs"></a>g_get_system_data_dirs ()</h3><a class="indexterm" name="id3021782"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* const * g_get_system_data_dirs (void);</pre><p>Returns an ordered list of base directories in which to access system-wide application data.</p><p>On Unix platforms this is determined using the mechanisms described inthe <a href="http://www.freedesktop.org/Standards/basedir-spec" target="_top">XDG Base Directory Specification</a></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a <code class="literal">NULL</code>-terminated array of strings owned by GLib that must not be modified or freed.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3021846"></a><h3><a name="g-get-system-config-dirs"></a>g_get_system_config_dirs ()</h3><a class="indexterm" name="id3021857"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* const * g_get_system_config_dirs (void);</pre><p>Returns an ordered list of base directories in which to access system-wide configuration information.</p><p>On Unix platforms this is determined using the mechanisms described inthe <a href="http://www.freedesktop.org/Standards/basedir-spec" target="_top">XDG Base Directory Specification</a></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> a <code class="literal">NULL</code>-terminated array of strings owned by GLib that must not be modified or freed.</td></tr></tbody></table></div><p>Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id3021922"></a><h3><a name="g-get-home-dir"></a>g_get_home_dir ()</h3><a class="indexterm" name="id3021933"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_home_dir (void);</pre><p>Gets the current user's home directory. </p><p>Note that in contrast to traditional Unix tools, this function prefers <code class="filename">passwd</code> entries over the <code class="envar">HOME</code> environment variable.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the current user's home directory.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3021986"></a><h3><a name="g-get-tmp-dir"></a>g_get_tmp_dir ()</h3><a class="indexterm" name="id3021997"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_tmp_dir (void);</pre><p>Gets the directory to use for temporary files.This is found from inspecting the environment variables <code class="envar">TMPDIR</code>, <code class="envar">TMP</code>, and <code class="envar">TEMP</code>in that order. If none of those are defined "/tmp" is returned on UNIX and "C:\" on Windows. The encoding of the returned string is system defined. On Windows, it is always UTF-8. The return value is never NULL.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the directory to use for temporary files.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3022051"></a><h3><a name="g-get-current-dir"></a>g_get_current_dir ()</h3><a class="indexterm" name="id3022062"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gchar">gchar</a>* g_get_current_dir (void);</pre><p>Gets the current directory.The returned string should be freed when no longer needed. The encoding of thereturned string is system defined. On Windows, it is always UTF-8.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the current directory.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3022101"></a><h3><a name="g-basename"></a>g_basename ()</h3><a class="indexterm" name="id3022112"></a><pre class="programlisting">const <a href="glib-Basic-Types.html#gchar">gchar</a>* g_basename (const <a href="glib-Basic-Types.html#gchar">gchar</a> *file_name);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">g_basename</code> is deprecated and should not be used in newly-written code. Use <a href="glib-Miscellaneous-Utility-Functions.html#g-path-get-basename"><code class="function">g_path_get_basename()</code></a> instead, but notice that<a href="glib-Miscellaneous-Utility-Functions.html#g-path-get-basename"><code class="function">g_path_get_basename()</code></a> allocates new memory for the returned string, unlikethis function which returns a pointer into the argument.</p></div><p>Gets the name of the file without any leading directory components. It returns a pointer into the given file name string.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>file_name</code></em> :</span></td><td> the name of the file.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the name of the file without any leading directory components.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3022210"></a><h3><a name="g-dirname"></a>g_dirname</h3><a class="indexterm" name="id3022220"></a><pre class="programlisting">#define g_dirname</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -