This
is what I do when I create a log file to write to:
filename = g_strdup_printf("mylog.log");
channel =
g_io_channel_new_file(filename,"a+",NULL);
if(channel == NULL)
{ g_error("failed to create new
file:'%s'",filename); return
FALSE; }
/* start top of log */ message = g_strdup_printf("Log
started on %s at %s\n\n", datestamp(), timestamp());
g_io_channel_write_chars(channel,
message,
-1,
&bytes,
NULL);
/* clean up */ g_free(message);
and when I go to clean up the channel and close the file, I
use:
/* close file */
g_io_channel_shutdown(channel,TRUE,NULL);
Regards,
Martyn
Hi there,
Thanks very much Martyn. Yeah I've had a look at
it but the "file descriptor" that is passed into the g_io_channel_unix_new
kinda confuses me. Also the g_io_channel_new_file returns a GIOChannel,
although hadn't I already created one using the g_io_channel_unix_new??? I'm
totally lost on it all :(...
Thanks
Uni
----- Original Message -----
Sent: Friday, February 07, 2003 4:59
PM
Subject: RE: File IO???
Have you looked at GLib IOChannels? http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html
Regards,
Martyn
Hi,
I'm interesting in something on File
input/output with GTK+. Could anybody please point me in the direction of
a tutorial or possibly give me a rough guide, as I only seem to be able to
pull up the "Hello World" tutorials or the API references...
Thanks very much!
Uni
|