From cc5147e1c9b493df12edc11ff0c14f641306b39b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 31 Jan 2015 10:50:46 +0100 Subject: [PATCH] Remove unused read_file_string --- file_ops.c | 60 ------------------------------------------------------ file_ops.h | 12 ----------- 2 files changed, 72 deletions(-) diff --git a/file_ops.c b/file_ops.c index 6c61ce43c4..5bc84ea2af 100644 --- a/file_ops.c +++ b/file_ops.c @@ -219,63 +219,3 @@ long read_file(const char *path, void **buf) #endif return read_generic_file(path,buf); } - -/** - * read_file_string: - * @path : path to file to be read from. - * @buf : buffer to allocate and read the contents of the - * file into. Needs to be freed manually. - * - * Reads file content as one string. - * - * Returns: true (1) on success, false (0) otherwise. - */ -bool read_file_string(const char *path, char **buf) -{ - long len = 0; - char *ptr = NULL; - FILE *file = fopen(path, "r"); - - *buf = NULL; - - if (!file) - goto error; - - /* ftell with "r" can be troublesome ... - * Haven't run into issues yet though. */ - fseek(file, 0, SEEK_END); - - /* Takes account of being able to read - * in EOF and '\0' at end. */ - len = ftell(file) + 2; - rewind(file); - - *buf = (char*)calloc(len, sizeof(char)); - if (!*buf) - goto error; - - ptr = *buf; - - while (ptr && !feof(file)) - { - size_t bufsize = (size_t)(((ptrdiff_t)*buf + - (ptrdiff_t)len) - (ptrdiff_t)ptr); - fgets(ptr, bufsize, file); - - ptr += strlen(ptr); - } - - ptr = strchr(ptr, EOF); - if (ptr) - *ptr = '\0'; - - fclose(file); - return true; - -error: - if (file) - fclose(file); - if (*buf) - free(*buf); - return false; -} diff --git a/file_ops.h b/file_ops.h index df51dec9a0..a566e4fd4f 100644 --- a/file_ops.h +++ b/file_ops.h @@ -50,18 +50,6 @@ long read_compressed_file(const char * path, void **buf, */ long read_file(const char *path, void **buf); -/** - * read_file_string: - * @path : path to file to be read from. - * @buf : buffer to allocate and read the contents of the - * file into. Needs to be freed manually. - * - * Reads file content as one string. - * - * Returns: true (1) on success, false (0) otherwise. - */ -bool read_file_string(const char *path, char **buf); - /** * write_file: * @path : path to file.