bl/textfileutils.c
changeset 69 1016349e619f
parent 13 eca715c100fe
     1.1 --- a/bl/textfileutils.c	Tue Jan 31 01:07:38 2012 +0000
     1.2 +++ b/bl/textfileutils.c	Tue May 28 15:17:19 2013 +0100
     1.3 @@ -3,26 +3,21 @@
     1.4  #include <bl/bl.h>
     1.5  
     1.6  /*
     1.7 - * Read a file into memory (which should be freed with mem_free when no
     1.8 + * Read a file into memory (which should be freed with g_free when no
     1.9   * longer required). Returns NULL on error and outputs a suitable error
    1.10   * message to stderr.
    1.11   * DOS-style line endings and UTF-8 BOM are handled transparently even
    1.12   * on platforms which don't normally use these formats.
    1.13   */
    1.14  gboolean file_get_contents_text(const char *filename,char **contents,
    1.15 -  size_t *length)
    1.16 +  size_t *length,GError **err)
    1.17  {
    1.18      int i;
    1.19      unsigned char *raw;
    1.20 -    size_t raw_length;
    1.21 +    gsize raw_length;
    1.22      GString *string;
    1.23 -    GError *error=NULL;
    1.24 -    if (!g_file_get_contents(filename,(char *)&raw,&raw_length,&error))
    1.25 -    {
    1.26 -	fprintf(stderr,"%s: %s\n",filename,error->message);
    1.27 -	g_error_free(error);
    1.28 +    if (!g_file_get_contents(filename,(char **)&raw,&raw_length,err))
    1.29  	return FALSE;
    1.30 -    }
    1.31      string=g_string_new(NULL);
    1.32      i=0;
    1.33      if (raw_length>=3 && raw[0]==0xEF && raw[1]==0xBB && raw[2]==0xBF)