diff -r 218904410231 -r f600b0d1fc5d gclib/fileutils.c --- a/gclib/fileutils.c Fri Jan 27 00:28:11 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#include -#include -#include -#include -#include -#include - -/* - * Read a file into memory (which should be freed with mem_free when no - * longer required). Returns FALSE on error and outputs a suitable error - * message to stderr. - */ -boolean file_get_contents(const char *filename,char **contents,size_t *length) -{ - FILE *fp; - size_t n; - char *buffer; - String *string; - fp=fopen(filename,"rb"); - if (!fp) - { - perror(filename); - return FALSE; - } - buffer=mem_new(char,1024); - string=string_new(NULL); - do - { - n=fread(buffer,1,1024,fp); - if (n<0) - { - perror(filename); - string_free(string,TRUE); - mem_free(buffer); - free(fp); - return FALSE; - } - string_append_len(string,buffer,n); - } while(n); - mem_free(buffer); - if (length) - *length=string->len; - *contents=string_free(string,FALSE); - fclose(fp); - return TRUE; -}