diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-09 20:09:55 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-09 20:09:55 -0300 |
commit | 502ed6760d9d2d674d0dcc87a6cb223ff079745d (patch) | |
tree | 1de3473703970658ecc84acefc2e917fb4f40d43 /src/loader.c | |
parent | beb44f4372e0af7dafc7fff6f5184737d61fc8d3 (diff) | |
download | blogc-502ed6760d9d2d674d0dcc87a6cb223ff079745d.tar.gz blogc-502ed6760d9d2d674d0dcc87a6cb223ff079745d.tar.bz2 blogc-502ed6760d9d2d674d0dcc87a6cb223ff079745d.zip |
loader: added tests
Diffstat (limited to 'src/loader.c')
-rw-r--r-- | src/loader.c | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/src/loader.c b/src/loader.c index 87abd8e..786fc05 100644 --- a/src/loader.c +++ b/src/loader.c @@ -10,10 +10,9 @@ #include <config.h> #endif /* HAVE_CONFIG_H */ -#include <errno.h> -#include <stdio.h> #include <string.h> #include "utils/utils.h" +#include "file.h" #include "source-parser.h" #include "template-parser.h" #include "loader.h" @@ -21,35 +20,6 @@ char* -blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err) -{ - if (err == NULL || *err != NULL) - return NULL; - - *len = 0; - FILE *fp = fopen(path, "r"); - - if (fp == NULL) { - int tmp_errno = errno; - *err = blogc_error_new_printf(BLOGC_ERROR_LOADER, - "Failed to open file (%s): %s", path, strerror(tmp_errno)); - return NULL; - } - - b_string_t *str = b_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; - b_string_append_len(str, buffer, read_len); - } - fclose(fp); - return b_string_free(str, false); -} - - -char* blogc_get_filename(const char *f) { if (f == NULL) |