diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index 3c106df27e..422768aee1 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -53,4 +53,7 @@ void *intfstream_init(intfstream_info_t *info); bool intfstream_resize(intfstream_internal_t *intf, intfstream_info_t *info); +bool intfstream_open(intfstream_internal_t *intf, + const char *path, unsigned mode, ssize_t len); + #endif diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index b183e2cc58..d07c983012 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -8,6 +8,11 @@ struct intfstream_internal { enum intfstream_type type; + struct + { + RFILE *fp; + } file; + struct { struct @@ -15,6 +20,7 @@ struct intfstream_internal uint8_t *data; unsigned size; } buf; + memstream_t *fp; } memory; }; @@ -39,6 +45,28 @@ bool intfstream_resize(intfstream_internal_t *intf, intfstream_info_t *info) return true; } +bool intfstream_open(intfstream_internal_t *intf, const char *path, unsigned mode, ssize_t len) +{ + if (!intf) + return false; + + switch (intf->type) + { + case INTFSTREAM_FILE: + intf->file.fp = filestream_open(path, mode, len); + if (!intf->file.fp) + return false; + break; + case INTFSTREAM_MEMORY: + intf->memory.fp = memstream_open(); + if (!intf->memory.fp) + return false; + break; + } + + return true; +} + void *intfstream_init(intfstream_info_t *info) { intfstream_internal_t *intf = NULL;