mirror of
https://github.com/libretro/hatari.git
synced 2026-11-07 10:36:00 -10:00
Check whether libretro.h supports the v4 retro_vfs_stat_64_t interface
Disable the corresponding code if it's not available, so we can finally enable the vfs.c code in the normal build, too.
This commit is contained in:
1 parent
3bbde0b20d
commit
60288c1ea7
6 files changed
+45
-18
No files matched your search
@@ -260,6 +260,12 @@ check_symbol_exists(ftello "stdio.h" HAVE_FTELLO)
|
||||
check_symbol_exists(flock "sys/file.h" HAVE_FLOCK)
|
||||
check_struct_has_member("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE)
|
||||
|
||||
if(ENABLE_LIBRETRO)
|
||||
check_struct_has_member("struct retro_vfs_interface" stat_64
|
||||
"${LIBRETRO_INCLUDE_DIR}/libretro.h"
|
||||
HAVE_RETRO_VFS_STAT_64_T)
|
||||
endif(ENABLE_LIBRETRO)
|
||||
|
||||
# #############
|
||||
# Other CFLAGS:
|
||||
# #############
|
||||
|
||||
@@ -99,6 +99,9 @@
|
||||
/* Define to 1 if you have the 'd_type' member in the 'dirent' struct */
|
||||
#cmakedefine HAVE_DIRENT_D_TYPE 1
|
||||
|
||||
/* Define to 1 if you have the retro_vfs_stat_64_t in libretro.h */
|
||||
#cmakedefine HAVE_RETRO_VFS_STAT_64_T 1
|
||||
|
||||
/* Relative path from bindir to datadir */
|
||||
#define BIN2DATADIR "@BIN2DATADIR@"
|
||||
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
|
||||
include_directories(. ../.. ../includes ../debug ../falcon)
|
||||
|
||||
add_library(UiRetro OBJECT audio.c disk_control.c harddisk.c joy_ui.c gui_event.c keymap.c
|
||||
main_retro.c microphone.c options.c screen.c statusbar.c timing.c)
|
||||
add_library(UiRetro OBJECT
|
||||
audio.c
|
||||
disk_control.c
|
||||
harddisk.c
|
||||
joy_ui.c
|
||||
gui_event.c
|
||||
keymap.c
|
||||
main_retro.c
|
||||
microphone.c
|
||||
options.c
|
||||
screen.c
|
||||
statusbar.c
|
||||
timing.c
|
||||
vfs.c)
|
||||
|
||||
target_include_directories(UiRetro PRIVATE ${LIBRETRO_INCLUDE_DIR})
|
||||
set_target_properties(UiRetro PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||
@@ -145,7 +145,7 @@ RETRO_API void retro_set_environment(retro_environment_t cb)
|
||||
libretro_set_core_options(cb, &categories_supported);
|
||||
|
||||
/* Retrieve VFS interface v4 or fall back if not available */
|
||||
//VFS_Init();
|
||||
VFS_Init();
|
||||
}
|
||||
|
||||
RETRO_API void retro_set_video_refresh(retro_video_refresh_t cb)
|
||||
|
||||
+19
-15
@@ -223,29 +223,34 @@ int64_t VFS_fsize(VFS_FILE stream)
|
||||
|
||||
bool VFS_FileExists(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
#if HAVE_RETRO_VFS_STAT_64_T
|
||||
if (VFS_IsActive() && vfs_iface->stat_64)
|
||||
{
|
||||
int64_t size = 0;
|
||||
int flags = vfs_iface->stat_64(path, &size);
|
||||
return (flags & RETRO_VFS_STAT_IS_VALID) && !(flags & RETRO_VFS_STAT_IS_DIRECTORY);
|
||||
}
|
||||
#endif
|
||||
|
||||
// fallback
|
||||
{
|
||||
struct stat st;
|
||||
return (stat(path, &st) == 0 &&
|
||||
(st.st_mode & (S_IRUSR|S_IWUSR)) && !S_ISDIR(st.st_mode));
|
||||
}
|
||||
return (stat(path, &st) == 0 &&
|
||||
(st.st_mode & (S_IRUSR|S_IWUSR)) && !S_ISDIR(st.st_mode));
|
||||
}
|
||||
|
||||
bool VFS_DirExists(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
#if HAVE_RETRO_VFS_STAT_64_T
|
||||
if (VFS_IsActive() && vfs_iface->stat_64)
|
||||
{
|
||||
int64_t size = 0;
|
||||
int flags = vfs_iface->stat_64(path, &size);
|
||||
return (flags & RETRO_VFS_STAT_IS_VALID) && (flags & RETRO_VFS_STAT_IS_DIRECTORY);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (VFS_IsActive() && vfs_iface->opendir && vfs_iface->closedir)
|
||||
{
|
||||
@@ -257,26 +262,25 @@ bool VFS_DirExists(const char *path)
|
||||
}
|
||||
|
||||
// fallback
|
||||
{
|
||||
struct stat st;
|
||||
return (stat(path, &st) == 0 && S_ISDIR(st.st_mode));
|
||||
}
|
||||
return (stat(path, &st) == 0 && S_ISDIR(st.st_mode));
|
||||
}
|
||||
|
||||
int64_t VFS_FileLength(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
#if HAVE_RETRO_VFS_STAT_64_T
|
||||
if (VFS_IsActive() && vfs_iface->stat_64)
|
||||
{
|
||||
int64_t size = 0;
|
||||
int flags = vfs_iface->stat_64(path, &size);
|
||||
return (flags & RETRO_VFS_STAT_IS_VALID) ? (int64_t)size : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// fallback
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(path, &st) == 0)
|
||||
return (int64_t)st.st_size;
|
||||
return -1;
|
||||
}
|
||||
if (stat(path, &st) == 0)
|
||||
return (int64_t)st.st_size;
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -80,6 +80,7 @@ static bool env_cb(unsigned cmd, void *data)
|
||||
case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY:
|
||||
case RETRO_ENVIRONMENT_GET_VARIABLE:
|
||||
case RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE:
|
||||
case RETRO_ENVIRONMENT_GET_VFS_INTERFACE:
|
||||
return false;
|
||||
case RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE:
|
||||
case RETRO_ENVIRONMENT_SET_GEOMETRY:
|
||||
|
||||
Reference in new issue
Block a user