[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: how to read a file, line by line, into a GString?
- From: Havoc Pennington <hp redhat com>
- To: Peter Jay Salzman <p dirac org>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: how to read a file, line by line, into a GString?
- Date: 27 Aug 2001 14:29:40 -0400
Peter Jay Salzman <p@dirac.org> writes:
>
> i'd like to read a file, line by line (discarding newlines) into a GString.
>
> i can't figure out how to do this without using an intermediary char *, which
> defeats the whole purpose of using GStrings in the first place.
>
> well, i CAN do it using GString foo->str, but of course, i want to use
> GString's access functions; not trample over its string data...
>
Look at the implementation of g_file_get_contents() in the unstable
version of GLib. This uses g_string_append_len() though, GLib 1.2
GString will not handle embedded nul bytes and doesn't have the
append_len function, so you'll need to modify it slightly.
Havoc
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]