6 * Read a file into memory (which should be freed with mem_free when no
7 * longer required). Returns NULL on error and outputs a suitable error
9 * DOS-style line endings are handled transparently even on platforms which
10 * don't normally use this format.
12 gboolean file_get_contents_text(const char *filename,char **contents,
20 if (!g_file_get_contents(filename,&raw,&raw_length,&error))
22 fprintf(stderr,"%s: %s\n",filename,error->message);
26 string=g_string_new(NULL);
27 for(i=0;i<raw_length;i++)
29 g_string_append_c(string,raw[i]);
34 *contents=g_string_free(string,FALSE);
36 g_string_free(string,TRUE);