Remove unused read_file_string

This commit is contained in:
twinaphex 2015-01-31 10:50:46 +01:00
parent 4e0a6c765d
commit cc5147e1c9
2 changed files with 0 additions and 72 deletions

View File

@ -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;
}

View File

@ -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.