1.1 --- a/bl/textfileutils.c Fri Jan 27 10:30:16 2012 +0000
1.2 +++ b/bl/textfileutils.c Fri Jan 27 16:18:02 2012 +0000
1.3 @@ -9,25 +9,30 @@
1.4 * DOS-style line endings are handled transparently even on platforms which
1.5 * don't normally use this format.
1.6 */
1.7 -boolean file_get_contents_text(const char *filename,char **contents,
1.8 +gboolean file_get_contents_text(const char *filename,char **contents,
1.9 size_t *length)
1.10 {
1.11 int i;
1.12 char *raw;
1.13 size_t raw_length;
1.14 - String *string;
1.15 - if (!file_get_contents(filename,&raw,&raw_length))
1.16 + GString *string;
1.17 + GError *error=NULL;
1.18 + if (!g_file_get_contents(filename,&raw,&raw_length,&error))
1.19 + {
1.20 + fprintf(stderr,"%s: %s\n",filename,error->message);
1.21 + g_error_free(error);
1.22 return FALSE;
1.23 - string=string_new(NULL);
1.24 + }
1.25 + string=g_string_new(NULL);
1.26 for(i=0;i<raw_length;i++)
1.27 if (raw[i]!='\r')
1.28 - string_append_c(string,raw[i]);
1.29 - mem_free(raw);
1.30 + g_string_append_c(string,raw[i]);
1.31 + g_free(raw);
1.32 if (length)
1.33 *length=string->len;
1.34 if (contents)
1.35 - *contents=string_free(string,FALSE);
1.36 + *contents=g_string_free(string,FALSE);
1.37 else
1.38 - string_free(string,TRUE);
1.39 + g_string_free(string,TRUE);
1.40 return TRUE;
1.41 }