Next: , Previous: Character Set Conversion, Up: Top


3 File Utilities

various file-related functions.

3.1 Overview

There is a group of functions which wrap the common POSIX functions dealing with filenames (g-open, g-rename, g-mkdir, g-stat, g-unlink, g-remove, g-fopen, g-freopen). The point of these wrappers is to make it possible to handle file names with any Unicode characters in them on Windows without having to use ifdefs and the wide character API in the application code.

The pathname argument should be in the GLib file name encoding. On POSIX this is the actual on-disk encoding which might correspond to the locale settings of the process (or the G_FILENAME_ENCODING environment variable), or not.

On Windows the GLib file name encoding is UTF-8. Note that the Microsoft C library does not use UTF-8, but has separate APIs for current system code page and wide characters (UTF-16). The GLib wrappers call the wide character API if present (on modern Windows systems), otherwise convert to/from the system code page.

Another group of functions allows to open and read directories in the GLib file name encoding. These are g-dir-open, g-dir-read-name, g-dir-rewind, g-dir-close.

3.2 Usage

— Function: g-file-error-from-errno (err_no int) ⇒  (ret <g-file-error>)

Gets a <g-file-error> constant based on the passed-in errno. For example, if you pass in ‘EEXIST’ this function returns <g-file-error-exist>. Unlike errno values, you can portably assume that all <g-file-error> values will exist.

Normally a <g-file-error> value goes into a <g-error> returned from a function that manipulates files. So you would use g-file-error-from-errno when constructing a <g-error>.

err-no
an "errno" value
ret
<g-file-error> corresponding to the given errno