IOChannel

A data structure representing an IO Channel. The fields should be considered private and should only be accessed with the following functions.

class IOChannel {}

Constructors

this
this(GIOChannel* gIOChannel, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(string filename, string mode)

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).

this
this(int fd)

Creates a new #GIOChannel given a file descriptor. On UNIX systems this works for plain files, pipes, and sockets.

Destructor

~this
~this()
Undocumented in source.

Members

Aliases

doref
alias doref = ref_
Undocumented in source.

Functions

close
void 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().

flush
GIOStatus flush()

Flushes the write buffer for the GIOChannel.

getBufferCondition
GIOCondition getBufferCondition()

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.

getBufferSize
size_t getBufferSize()

Gets the buffer size.

getBuffered
bool getBuffered()

Returns whether @channel is buffered.

getCloseOnUnref
bool getCloseOnUnref()

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.

getEncoding
string getEncoding()

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.

getFlags
GIOFlags getFlags()

Gets the current flags for a #GIOChannel, including read-only flags such as %G_IO_FLAG_IS_READABLE.

getIOChannelStruct
GIOChannel* getIOChannelStruct(bool transferOwnership)

Get the main Gtk struct

getLineTerm
string getLineTerm(int* length)

This returns the string that #GIOChannel uses to determine where in the file a line break occurs. A value of %NULL indicates autodetection.

getStruct
void* getStruct()

the main Gtk struct as a void*

init
void init()

Initializes a #GIOChannel struct.

read
GIOError read(string buf, size_t count, size_t* bytesRead)

Reads data from a #GIOChannel.

readChars
GIOStatus readChars(char[] buf, size_t bytesRead)

Replacement for g_io_channel_read() with the new API.

readLine
GIOStatus readLine(string strReturn, size_t terminatorPos)

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.

readLineString
GIOStatus readLineString(StringG buffer, size_t terminatorPos)

Reads a line from a #GIOChannel, using a #GString as a buffer.

readToEnd
GIOStatus readToEnd(string strReturn)

Reads all the remaining data from the file.

readUnichar
GIOStatus readUnichar(dchar thechar)

Reads a Unicode character from @channel. This function cannot be called on a channel with %NULL encoding.

ref_
IOChannel ref_()

Increments the reference count of a #GIOChannel.

seek
GIOError seek(long offset, GSeekType type)

Sets the current position in the #GIOChannel, similar to the standard library function fseek().

seekPosition
GIOStatus seekPosition(long offset, GSeekType type)

Replacement for g_io_channel_seek() with the new API.

setBufferSize
void setBufferSize(size_t size)

Sets the buffer size.

setBuffered
void setBuffered(bool buffered)

The buffering state can only be set if the channel's encoding is %NULL. For any other encoding, the channel must be buffered.

setCloseOnUnref
void setCloseOnUnref(bool doClose)

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.

setEncoding
GIOStatus setEncoding(string 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.

setFlags
GIOStatus setFlags(GIOFlags flags)

Sets the (writeable) flags in @channel to (@flags & %G_IO_FLAG_SET_MASK).

setLineTerm
void setLineTerm(string lineTerm, int length)

This sets the string that #GIOChannel uses to determine where in the file a line break occurs.

shutdown
GIOStatus shutdown(bool flush)

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().

unixGetFd
int unixGetFd()

Returns the file descriptor of the #GIOChannel.

unref
void unref()

Decrements the reference count of a #GIOChannel.

write
GIOError write(string buf, size_t count, size_t* bytesWritten)

Writes data to a #GIOChannel.

writeChars
GIOStatus writeChars(string buf, size_t bytesWritten)

Replacement for g_io_channel_write() with the new API.

writeUnichar
GIOStatus writeUnichar(dchar thechar)

Writes a Unicode character to @channel. This function cannot be called on a channel with %NULL encoding.

Static functions

errorFromErrno
GIOChannelError errorFromErrno(int en)

Converts an errno error number to a #GIOChannelError.

errorQuark
GQuark errorQuark()
ioAddWatch
uint ioAddWatch(IOChannel channel, GIOCondition condition, GIOFunc func, void* userData)

Adds the #GIOChannel into the default main loop context with the default priority.

ioAddWatchFull
uint ioAddWatchFull(IOChannel channel, int priority, GIOCondition condition, GIOFunc func, void* userData, GDestroyNotify notify)

Adds the #GIOChannel into the default main loop context with the given priority.

ioCreateWatch
Source ioCreateWatch(IOChannel channel, GIOCondition condition)

Creates a #GSource that's dispatched when @condition is met for the given @channel. For example, if condition is #G_IO_IN, the source will be dispatched when there's data available for reading.

Variables

gIOChannel
GIOChannel* gIOChannel;

the main Gtk struct

ownedRef
bool ownedRef;
Undocumented in source.

Meta