Function

GLibIOChannelnew_file

Declaration [src]

GIOChannel*
g_io_channel_new_file (
  const gchar* filename,
  const gchar* mode,
  GError** error
)

Description [src]

Open a file filename as a GIOChannel using mode mode. This channel will be closed when the last reference to it is dropped, so there is no need to call g_io_channel_close() (though doing so will not cause problems, as long as no attempt is made to access the channel after it is closed).

Parameters

filename

Type: const gchar*

A string containing the name of a file.

The data is owned by the caller of the function.
The value is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.
mode

Type: const gchar*

One of “r”, “w”, “a”, “r+”, “w+”, “a+”. These have the same meaning as in fopen().

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the function if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: GIOChannel

A GIOChannel on success, NULL on failure.

The caller of the function takes ownership of the data, and is responsible for freeing it.