Rewrite zr_common_file_load to use file_stream.h

This commit is contained in:
twinaphex 2016-03-22 01:16:08 +01:00
parent 79008d4fd6
commit e9fd6863ce

View File

@ -15,6 +15,8 @@
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <streams/file_stream.h>
#include "zr_common.h" #include "zr_common.h"
#include "../menu_display.h" #include "../menu_display.h"
@ -35,16 +37,10 @@ struct zr_image zr_common_image_load(const char *filename)
char* zr_common_file_load(const char* path, size_t* size) char* zr_common_file_load(const char* path, size_t* size)
{ {
char *buf; void *buf;
FILE *fd = fopen(path, "rb"); ssize_t *length = (ssize_t*)size;
retro_read_file(path, &buf, length);
fseek(fd, 0, SEEK_END); return (char*)buf;
*size = (size_t)ftell(fd);
fseek(fd, 0, SEEK_SET);
buf = (char*)calloc(*size, 1);
fread(buf, *size, 1, fd);
fclose(fd);
return buf;
} }
void zr_common_device_init(struct zr_device *dev) void zr_common_device_init(struct zr_device *dev)