(file_ops.c) Simplify read_file
This commit is contained in:
parent
323475c516
commit
3ebcfad8c0
10
file_ops.c
10
file_ops.c
|
@ -85,7 +85,7 @@ bool write_file(const char *path, const void *data, ssize_t size)
|
||||||
*
|
*
|
||||||
* Returns: number of items read, -1 on error.
|
* Returns: number of items read, -1 on error.
|
||||||
*/
|
*/
|
||||||
static bool read_generic_file(const char *path, void **buf, ssize_t *len)
|
static int read_generic_file(const char *path, void **buf, ssize_t *len)
|
||||||
{
|
{
|
||||||
long ret = 0, _len = 0;
|
long ret = 0, _len = 0;
|
||||||
void *rom_buf = NULL;
|
void *rom_buf = NULL;
|
||||||
|
@ -127,7 +127,7 @@ static bool read_generic_file(const char *path, void **buf, ssize_t *len)
|
||||||
if (len)
|
if (len)
|
||||||
*len = ret;
|
*len = ret;
|
||||||
|
|
||||||
return true;
|
return 1;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (file)
|
if (file)
|
||||||
|
@ -137,7 +137,7 @@ error:
|
||||||
if (len)
|
if (len)
|
||||||
*len = -1;
|
*len = -1;
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_COMPRESSION
|
#ifdef HAVE_COMPRESSION
|
||||||
|
@ -240,7 +240,5 @@ int read_file(const char *path, void **buf, ssize_t *length)
|
||||||
if (read_compressed_file(path, buf, NULL, length))
|
if (read_compressed_file(path, buf, NULL, length))
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
if (read_generic_file(path, buf, length))
|
return read_generic_file(path, buf, length);
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue