mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 09:32:52 +00:00
Add VFS support to imageviewer (should get Unicode filenames working on Windows too, even without VFS)
This commit is contained in:
parent
29b9ec0b5e
commit
c88e5e08a0
@ -1,5 +1,6 @@
|
||||
image_core.so:
|
||||
image_core.so: image_core.c
|
||||
gcc \
|
||||
-g \
|
||||
image_core.c \
|
||||
../../libretro-common/file/file_path.c \
|
||||
../../libretro-common/lists/dir_list.c \
|
||||
@ -7,10 +8,13 @@ image_core.so:
|
||||
../../libretro-common/compat/compat_strcasestr.c \
|
||||
../../libretro-common/lists/string_list.c \
|
||||
../../libretro-common/file/retro_dirent.c \
|
||||
../../libretro-common/streams/file_stream.c \
|
||||
../../libretro-common/vfs/vfs_implementation.c \
|
||||
-o image_core.so \
|
||||
-DHAVE_STB_IMAGE \
|
||||
-I ../../libretro-common/include/ \
|
||||
-I../../deps/stb \
|
||||
-Wl,--no-undefined \
|
||||
-shared \
|
||||
-fPIC \
|
||||
-lm
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <compat/strl.h>
|
||||
#include <retro_environment.h>
|
||||
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#if defined(HAVE_RPNG) || defined(HAVE_RJPEG) || defined(HAVE_RTGA) || defined(HAVE_RBMP)
|
||||
#define PREFER_NON_STB_IMAGE
|
||||
#endif
|
||||
@ -157,10 +159,19 @@ void IMAGE_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
|
||||
static const struct retro_variable vars[] = {
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
|
||||
struct retro_vfs_interface_info vfs_iface_info = { 1, NULL };
|
||||
|
||||
IMAGE_CORE_PREFIX(environ_cb) = cb;
|
||||
|
||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
||||
|
||||
#ifndef RARCH_INTERNAL
|
||||
/* I don't trust filestream_vfs_init to work inside rarch */
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VFS_INTERFACE, &vfs_iface_info))
|
||||
filestream_vfs_init(&vfs_iface_info);
|
||||
#endif
|
||||
}
|
||||
|
||||
void IMAGE_CORE_PREFIX(retro_set_video_refresh)(retro_video_refresh_t cb)
|
||||
@ -227,6 +238,9 @@ static bool imageviewer_load(const char *path, int image_index)
|
||||
{
|
||||
#ifdef STB_IMAGE_IMPLEMENTATION
|
||||
int comp;
|
||||
RFILE* f;
|
||||
size_t len;
|
||||
void* buf;
|
||||
#endif
|
||||
#ifdef RARCH_INTERNAL
|
||||
extern bool video_driver_supports_rgba(void);
|
||||
@ -235,12 +249,17 @@ static bool imageviewer_load(const char *path, int image_index)
|
||||
imageviewer_free_image();
|
||||
|
||||
#ifdef STB_IMAGE_IMPLEMENTATION
|
||||
image_buffer = (uint32_t*)stbi_load(
|
||||
path,
|
||||
&image_width,
|
||||
&image_height,
|
||||
&comp,
|
||||
4);
|
||||
f = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ, 0);
|
||||
len = filestream_get_size(f);
|
||||
buf = malloc(len);
|
||||
filestream_read(f, buf, len);
|
||||
filestream_close(f);
|
||||
|
||||
image_buffer = (uint32_t*)stbi_load_from_memory(
|
||||
buf, len,
|
||||
&image_width, &image_height,
|
||||
&comp, 4);
|
||||
free(buf);
|
||||
#else
|
||||
#ifdef RARCH_INTERNAL
|
||||
image_texture.supports_rgba = video_driver_supports_rgba();
|
||||
|
@ -182,6 +182,11 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns
|
||||
const char *mode_str = NULL;
|
||||
libretro_vfs_implementation_file *stream = (libretro_vfs_implementation_file*)calloc(1, sizeof(*stream));
|
||||
|
||||
#ifdef VFS_FRONTEND
|
||||
const char * dumb_prefix = "vfsonly://";
|
||||
if (!memcmp(path, dumb_prefix, strlen(dumb_prefix))) path += strlen(dumb_prefix);
|
||||
#endif
|
||||
|
||||
if (!stream)
|
||||
return NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user