📄 misc_utils.sgml
字号:
<para>Gets the name of the file without any leadingdirectory components. It returns a pointer into the given file namestring.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>file_name</parameter> :</entry><entry>the name of the file.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the name of the file without any leading directory components.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-dirname">g_dirname</title><programlisting>#define g_dirname</programlisting><warning><para><literal>g_dirname</literal> is deprecated and should not be used in newly-written code.</para></warning><para>This function is deprecated and will be removed in the next majorrelease of GLib. Use <link linkend="g-path-get-dirname">g_path_get_dirname</link>() instead.</para><para>Gets the directory components of a file name.If the file name has no directory components "." is returned.The returned string should be freed when no longer needed.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the directory components of the file.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-path-is-absolute">g_path_is_absolute ()</title><programlisting><link linkend="gboolean">gboolean</link> g_path_is_absolute (const <link linkend="gchar">gchar</link> *file_name);</programlisting><para>Returns <literal>TRUE</literal> if the given <parameter>file_name</parameter> is an absolute file name,i.e. it contains a full path from the root directory such as '/usr/local'on UNIX or 'C:\windows' on Windows systems.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>file_name</parameter> :</entry><entry>a file name.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if <parameter>file_name</parameter> is an absolute path.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-path-skip-root">g_path_skip_root ()</title><programlisting>G_CONST_RETURN <link linkend="gchar">gchar</link>* g_path_skip_root (const <link linkend="gchar">gchar</link> *file_name);</programlisting><para>Returns a pointer into <parameter>file_name</parameter> after the root component, i.e. afterthe '/' in UNIX or 'C:\' under Windows. If <parameter>file_name</parameter> is not an absolutepath it returns <literal>NULL</literal>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>file_name</parameter> :</entry><entry>a file name.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a pointer into <parameter>file_name</parameter> after the root component.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-path-get-basename">g_path_get_basename ()</title><programlisting><link linkend="gchar">gchar</link>* g_path_get_basename (const <link linkend="gchar">gchar</link> *file_name);</programlisting><para>Gets the name of the file without any leading directory components.The returned string should be freed when no longer needed.</para><note><para>This function allocates new memory for the returned string. This isdifferent from the old <link linkend="g-basename">g_basename</link>() function, which returned a pointerinto the argument.</para></note><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>file_name</parameter> :</entry><entry>the name of the file.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the name of the file without any leading directory components.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-path-get-dirname">g_path_get_dirname ()</title><programlisting><link linkend="gchar">gchar</link>* g_path_get_dirname (const <link linkend="gchar">gchar</link> *file_name);</programlisting><para>Gets the directory components of a file name. If the file name has nodirectory components "." is returned. The returned string should befreed when no longer needed.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>file_name</parameter> :</entry><entry>the name of the file.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the directory components of the file.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-build-filename">g_build_filename ()</title><programlisting><link linkend="gchar">gchar</link>* g_build_filename (const <link linkend="gchar">gchar</link> *first_element, ...);</programlisting><para>Creates a filename from a series of elements using the correctseparator for filenames. This function behaves identicallyto <literal>g_build_path (G_DIR_SEPARATOR_S, first_element, ....)</literal>.</para><para>No attempt is made to force the resulting filename to be an absolutepath. If the first element is a relative path, the result willbe a relative path.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>first_element</parameter> :</entry><entry> the first element in the path</entry></row><row><entry align="right"><parameter>...</parameter> :</entry><entry> remaining elements in path</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a newly-allocated string that must be freed with <link linkend="g-free">g_free</link>().</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-build-path">g_build_path ()</title><programlisting><link linkend="gchar">gchar</link>* g_build_path (const <link linkend="gchar">gchar</link> *separator, const <link linkend="gchar">gchar</link> *first_element, ...);</programlisting><para>Creates a path from a series of elements using <parameter>separator</parameter> as theseparator between elements. At the boundary between two elements,any trailing occurrences of separator in the first element, orleading occurrences of separator in the second element are removedand exactly one copy of the separator is inserted.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>separator</parameter> :</entry><entry> a string used to separator the elements of the path.</entry></row><row><entry align="right"><parameter>first_element</parameter> :</entry><entry> the first element in the path</entry></row><row><entry align="right"><parameter>...</parameter> :</entry><entry> remaining elements in path</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> a newly-allocated string that must be freed with <link linkend="g-free">g_free</link>().</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-find-program-in-path">g_find_program_in_path ()</title><programlisting><link linkend="gchar">gchar</link>* g_find_program_in_path (const <link linkend="gchar">gchar</link> *program);</programlisting><para>Locates the first executable named <parameter>program</parameter> in the user's path, in thesame way that <link linkend="execvp">execvp</link>() would locate it. Returns an allocated stringwith the absolute path name, or NULL if the program is not found inthe path. If <parameter>program</parameter> is already an absolute path, returns a copy of<parameter>program</parameter> if <parameter>program</parameter> exists and is executable, and NULL otherwise.</para><para>On Windows, if <parameter>program</parameter> does not have a file type suffix, tries toappend the suffixes in the PATHEXT environment variable (if thatdoesn't exists, the suffixes .com, .exe, and .bat) in turn, andthen look for the resulting file name in the same way as<link linkend="CreateProcess">CreateProcess</link>() would. This means first in the directory where theprogram was loaded from, then in the current directory, then in theWindows 32-bit system directory, then in the Windows directory, andfinally in the directories in the PATH environment variable. Ifthe program is found, the return value contains the full nameincluding the type suffix.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>program</parameter> :</entry><entry> a program name</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> absolute path, or NULL</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-bit-nth-lsf">g_bit_nth_lsf ()</title><programlisting><link linkend="gint">gint</link> g_bit_nth_lsf (<link linkend="gulong">gulong</link> mask,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -