3 #include <gclib/gclib.h>
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 boolean file_get_contents_text(const char *filename,char **contents,
19 if (!file_get_contents(filename,&raw,&raw_length))
21 string=string_new(NULL);
22 for(i=0;i<raw_length;i++)
24 string_append_c(string,raw[i]);
29 *contents=string_free(string,FALSE);
31 string_free(string,TRUE);