mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-21 10:11:18 +00:00
Remove unused read_file_string
This commit is contained in:
parent
4e0a6c765d
commit
cc5147e1c9
60
file_ops.c
60
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;
|
||||
}
|
||||
|
12
file_ops.h
12
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user