g_file_set_contents equivalent in libpurple?
mark at kingant.net
Tue Jul 10 02:44:23 EDT 2007
On Sun, 8 Jul 2007 01:01:23 -0400, William Ehlhardt wrote
> In building the public-key certificate interface, I need to load and
> store large binary blobs of data from and to files on disk (for
> import/export functionality). For loading, g_file_get_contents meets
> my need. For storing, purple_util_write_data_to_file is *almost*
> ideal, but it is limited to files in ~/.purple, while I would like to
> have access to any path in the filesystem.
> g_file_set_contents  seems ideal for this purpose, but
> unfortunately was introduced in glib 2.8, making it a
> backwards-compatibility problem. How should I handle this? For now, I
> have simply used g_file_set_contents .
Copying the implementation of glib's g_file_set_contents() to
purple_file_set_contents() in libpurple/util.c is the probably the best course
of action. See purple_str_has_prefix() in that same file for a simple example
of how to do this.
I think that function could be used in a lot of places where we currently use
open/write/close, but I don't think we're ready to force Pidgin users to have
glib 2.8.0 (I'm cool with Pidgin 3.0.0 requiring glib 2.6.0 or higher).
More information about the Devel