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

📄 fileutils.sgml

📁 GLib是GTK+和GNOME工程的基础底层核心程序库
💻 SGML
📖 第 1 页 / 共 2 页
字号:
<refentry id="glib-File-Utilities"><refmeta><refentrytitle>File Utilities</refentrytitle><manvolnum>3</manvolnum><refmiscinfo>GLIB Library</refmiscinfo></refmeta><refnamediv><refname>File Utilities</refname><refpurpose>various file-related functions.</refpurpose></refnamediv><refsynopsisdiv><title>Synopsis</title><synopsis>#include &lt;glib.h&gt;enum        <link linkend="GFileError">GFileError</link>;#define     <link linkend="G-FILE-ERROR-CAPS">G_FILE_ERROR</link>enum        <link linkend="GFileTest">GFileTest</link>;<link linkend="GFileError">GFileError</link>  <link linkend="g-file-error-from-errno">g_file_error_from_errno</link>         (<link linkend="gint">gint</link> err_no);<link linkend="gboolean">gboolean</link>    <link linkend="g-file-get-contents">g_file_get_contents</link>             (const <link linkend="gchar">gchar</link> *filename,                                             <link linkend="gchar">gchar</link> **contents,                                             <link linkend="gsize">gsize</link> *length,                                             <link linkend="GError">GError</link> **error);<link linkend="gboolean">gboolean</link>    <link linkend="g-file-test">g_file_test</link>                     (const <link linkend="gchar">gchar</link> *filename,                                             <link linkend="GFileTest">GFileTest</link> test);int         <link linkend="g-mkstemp">g_mkstemp</link>                       (char *tmpl);int         <link linkend="g-file-open-tmp">g_file_open_tmp</link>                 (const char *tmpl,                                             char **name_used,                                             <link linkend="GError">GError</link> **error);struct      <link linkend="GDir">GDir</link>;<link linkend="GDir">GDir</link>*       <link linkend="g-dir-open">g_dir_open</link>                      (const <link linkend="gchar">gchar</link> *path,                                             <link linkend="guint">guint</link> flags,                                             <link linkend="GError">GError</link> **error);G_CONST_RETURN <link linkend="gchar">gchar</link>* <link linkend="g-dir-read-name">g_dir_read_name</link>       (<link linkend="GDir">GDir</link> *dir);void        <link linkend="g-dir-rewind">g_dir_rewind</link>                    (<link linkend="GDir">GDir</link> *dir);void        <link linkend="g-dir-close">g_dir_close</link>                     (<link linkend="GDir">GDir</link> *dir);</synopsis></refsynopsisdiv><refsect1><title>Description</title><para></para></refsect1><refsect1><title>Details</title><refsect2><title><anchor id="GFileError">enum GFileError</title><programlisting>typedef enum{  G_FILE_ERROR_EXIST,  G_FILE_ERROR_ISDIR,  G_FILE_ERROR_ACCES,  G_FILE_ERROR_NAMETOOLONG,  G_FILE_ERROR_NOENT,  G_FILE_ERROR_NOTDIR,  G_FILE_ERROR_NXIO,  G_FILE_ERROR_NODEV,  G_FILE_ERROR_ROFS,  G_FILE_ERROR_TXTBSY,  G_FILE_ERROR_FAULT,  G_FILE_ERROR_LOOP,  G_FILE_ERROR_NOSPC,  G_FILE_ERROR_NOMEM,  G_FILE_ERROR_MFILE,  G_FILE_ERROR_NFILE,  G_FILE_ERROR_BADF,  G_FILE_ERROR_INVAL,  G_FILE_ERROR_PIPE,  G_FILE_ERROR_AGAIN,  G_FILE_ERROR_INTR,  G_FILE_ERROR_IO,  G_FILE_ERROR_PERM,  G_FILE_ERROR_FAILED} GFileError;</programlisting><para>Values corresponding to <literal>errno</literal> codes returned from file operationson UNIX. Unlike <literal>errno</literal> codes, <link linkend="GFileError">GFileError</link> values are available on all systems, even Windows. The exact meaning of each code depends on whatsort of file operation you were performing; the UNIX documentationgives more details. The following error code descriptions come from the GNU C Library manual, and are under the copyrightof that manual.</para><para>It's not very portable to make detailed assumptions about exactlywhich errors will be returned from a given operation. Some errorsdon't occur on some systems, etc., sometimes there are subtledifferences in when a system will report a given error, etc.</para><informaltable pgwide="1" frame="none" role="enum"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry><literal>G_FILE_ERROR_EXIST</literal></entry><entry>Operation not permitted; only the owner of the     file (or other resource) or processes with special privileges can     perform the operation.</entry></row><row><entry><literal>G_FILE_ERROR_ISDIR</literal></entry><entry>File is a directory; you cannot open a directory     for writing, or create or remove hard links to it.</entry></row><row><entry><literal>G_FILE_ERROR_ACCES</literal></entry><entry>Permission denied; the file permissions do not     allow the attempted operation.</entry></row><row><entry><literal>G_FILE_ERROR_NAMETOOLONG</literal></entry><entry>Filename too long.</entry></row><row><entry><literal>G_FILE_ERROR_NOENT</literal></entry><entry>No such file or directory.  This is a "file     doesn't exist" error for ordinary files that are referenced in     contexts where they are expected to already exist.</entry></row><row><entry><literal>G_FILE_ERROR_NOTDIR</literal></entry><entry>A file that isn't a directory was specified when     a directory is required.</entry></row><row><entry><literal>G_FILE_ERROR_NXIO</literal></entry><entry>No such device or address.  The system tried to     use the device represented by a file you specified, and it     couldn't find the device.  This can mean that the device file was     installed incorrectly, or that the physical device is missing or     not correctly attached to the computer.</entry></row><row><entry><literal>G_FILE_ERROR_NODEV</literal></entry><entry>This file is of a type that doesn't support     mapping.</entry></row><row><entry><literal>G_FILE_ERROR_ROFS</literal></entry><entry>The directory containing the new link can't be          modified because it's on a read-only file system.</entry></row><row><entry><literal>G_FILE_ERROR_TXTBSY</literal></entry><entry>Text file busy.</entry></row><row><entry><literal>G_FILE_ERROR_FAULT</literal></entry><entry>You passed in a pointer to bad memory.  (GLib won't reliably return this, don't pass in pointers to bad  memory.)</entry></row><row><entry><literal>G_FILE_ERROR_LOOP</literal></entry><entry>Too many levels of symbolic links were encountered  in looking up a file name.  This often indicates a cycle of symbolic  links.</entry></row><row><entry><literal>G_FILE_ERROR_NOSPC</literal></entry><entry>No space left on device; write operation on a  file failed because the disk is full.</entry></row><row><entry><literal>G_FILE_ERROR_NOMEM</literal></entry><entry>No memory available.  The system cannot allocate     more virtual memory because its capacity is full.</entry></row><row><entry><literal>G_FILE_ERROR_MFILE</literal></entry><entry>The current process has too many files open and     can't open any more.  Duplicate descriptors do count toward this     limit.</entry></row><row><entry><literal>G_FILE_ERROR_NFILE</literal></entry><entry>There are too many distinct file openings in the     entire system.</entry></row><row><entry><literal>G_FILE_ERROR_BADF</literal></entry><entry>Bad file descriptor; for example, I/O on a     descriptor that has been closed or reading from a descriptor open     only for writing (or vice versa).</entry></row><row><entry><literal>G_FILE_ERROR_INVAL</literal></entry><entry>Invalid argument.  This is used to indicate     various kinds of problems with passing the wrong argument to a     library function.</entry></row><row><entry><literal>G_FILE_ERROR_PIPE</literal></entry><entry>Broken pipe; there is no process reading from the     other end of a pipe.  Every library function that returns this     error code also generates a `SIGPIPE' signal; this signal     terminates the program if not handled or blocked.  Thus, your     program will never actually see this code unless it has handled or     blocked `SIGPIPE'.</entry></row><row><entry><literal>G_FILE_ERROR_AGAIN</literal></entry><entry>Resource temporarily unavailable; the call might     work if you try again later.</entry></row><row><entry><literal>G_FILE_ERROR_INTR</literal></entry><entry>Interrupted function call; an asynchronous signal     occurred and prevented completion of the call.  When this     happens, you should try the call again.</entry></row><row><entry><literal>G_FILE_ERROR_IO</literal></entry><entry>Input/output error; usually used for physical read    or write errors. i.e. the disk or other physical device hardware    is returning errors.</entry></row><row><entry><literal>G_FILE_ERROR_PERM</literal></entry><entry>Operation not permitted; only the owner of the     file (or other resource) or processes with special privileges can     perform the operation.</entry></row><row><entry><literal>G_FILE_ERROR_FAILED</literal></entry><entry>Does not correspond to a UNIX error code; this  is the standard "failed for unspecified reason" error code present in   all <link linkend="GError">GError</link> error code enumerations. Returned if no specific  code applies.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="G-FILE-ERROR-CAPS">G_FILE_ERROR</title><programlisting>#define G_FILE_ERROR g_file_error_quark ()</programlisting><para>Error domain for file operations. Errors in this domain willbe from the <link linkend="GFileError">GFileError</link> enumeration. See <link linkend="GError">GError</link> for information on error domains.</para></refsect2><refsect2><title><anchor id="GFileTest">enum GFileTest</title><programlisting>typedef enum{  G_FILE_TEST_IS_REGULAR    = 1 &lt;&lt; 0,  G_FILE_TEST_IS_SYMLINK    = 1 &lt;&lt; 1,  G_FILE_TEST_IS_DIR        = 1 &lt;&lt; 2,  G_FILE_TEST_IS_EXECUTABLE = 1 &lt;&lt; 3,  G_FILE_TEST_EXISTS        = 1 &lt;&lt; 4} GFileTest;</programlisting><para>A test to perform an a file using <link linkend="g-file-test">g_file_test</link>().</para><informaltable pgwide="1" frame="none" role="enum"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry><literal>G_FILE_TEST_IS_REGULAR</literal></entry>

⌨️ 快捷键说明

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