diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-03-19 10:36:16 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-03-19 10:36:16 +0100 |
commit | c7b4bc4d64a3ce669e54b7c7dae87527d9ee3123 (patch) | |
tree | e5f5ccf4d0d177cb8dd55b6f8ad026c18a2310a9 /src/file.c | |
parent | 37592b57b31987519e59117d49bccd0207e67f15 (diff) | |
download | blogc-c7b4bc4d64a3ce669e54b7c7dae87527d9ee3123.tar.gz blogc-c7b4bc4d64a3ce669e54b7c7dae87527d9ee3123.tar.bz2 blogc-c7b4bc4d64a3ce669e54b7c7dae87527d9ee3123.zip |
main: loader: use file utils from squareball
Diffstat (limited to 'src/file.c')
-rw-r--r-- | src/file.c | 26 |
1 files changed, 1 insertions, 25 deletions
@@ -10,10 +10,8 @@ #include <config.h> #endif /* HAVE_CONFIG_H */ -#include <errno.h> #include <stdarg.h> #include <stdio.h> -#include <string.h> #include <squareball.h> #include "file.h" #include "error.h" @@ -25,29 +23,7 @@ char* blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err) { - if (path == NULL || err == NULL || *err != NULL) - return NULL; - - *len = 0; - FILE *fp = fopen(path, "r"); - - if (fp == NULL) { - int tmp_errno = errno; - *err = sb_error_new_printf(BLOGC_ERROR_LOADER, - "Failed to open file (%s): %s", path, strerror(tmp_errno)); - return NULL; - } - - sb_string_t *str = sb_string_new(); - char buffer[BLOGC_FILE_CHUNK_SIZE]; - - while (!feof(fp)) { - size_t read_len = fread(buffer, sizeof(char), BLOGC_FILE_CHUNK_SIZE, fp); - *len += read_len; - sb_string_append_len(str, buffer, read_len); - } - fclose(fp); - return sb_string_free(str, false); + return sb_file_get_contents(path, len, err); } |