Struct
GLibIOChannel
Constructors
g_io_channel_new_file
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).
g_io_channel_unix_new
Creates a new GIOChannel
given a file descriptor. On UNIX systems
this works for plain files, pipes, and sockets.
Instance methods
g_io_channel_close
Close an IO channel. Any pending data to be written will be flushed, ignoring errors. The channel will not be freed until the last reference is dropped using g_io_channel_unref().
deprecated: 2.2
g_io_channel_get_buffer_condition
This function returns a GIOCondition
depending on whether there
is data to be read/space to write data in the internal buffers in
the GIOChannel
. Only the flags G_IO_IN
and G_IO_OUT
may be set.
g_io_channel_get_close_on_unref
Returns whether the file/socket/whatever associated with channel
will be closed when channel
receives its final unref and is
destroyed. The default value of this is TRUE
for channels created
by g_io_channel_new_file (), and FALSE
for all other channels.
g_io_channel_get_encoding
Gets the encoding for the input/output of the channel.
The internal encoding is always UTF-8. The encoding NULL
makes the channel safe for binary data.
g_io_channel_get_flags
Gets the current flags for a GIOChannel
, including read-only
flags such as G_IO_FLAG_IS_READABLE
.
g_io_channel_get_line_term
This returns the string that GIOChannel
uses to determine
where in the file a line break occurs. A value of NULL
indicates autodetection.
g_io_channel_read_line
Reads a line, including the terminating character(s),
from a GIOChannel
into a newly-allocated string.
str_return
will contain allocated memory if the return
is G_IO_STATUS_NORMAL
.
g_io_channel_read_unichar
Reads a Unicode character from channel
.
This function cannot be called on a channel with NULL
encoding.
g_io_channel_seek
Sets the current position in the GIOChannel
, similar to the standard
library function fseek().
deprecated: 2.2
g_io_channel_set_buffered
The buffering state can only be set if the channel’s encoding
is NULL
. For any other encoding, the channel must be buffered.
g_io_channel_set_close_on_unref
Whether to close the channel on the final unref of the GIOChannel
data structure. The default value of this is TRUE
for channels
created by g_io_channel_new_file (), and FALSE
for all other channels.
g_io_channel_set_encoding
Sets the encoding for the input/output of the channel. The internal encoding is always UTF-8. The default encoding for the external file is UTF-8.
g_io_channel_set_line_term
This sets the string that GIOChannel
uses to determine
where in the file a line break occurs.
g_io_channel_shutdown
Close an IO channel. Any pending data to be written will be
flushed if flush
is TRUE
. The channel will not be freed until the
last reference is dropped using g_io_channel_unref().
g_io_channel_write_unichar
Writes a Unicode character to channel
.
This function cannot be called on a channel with NULL
encoding.