(UWP) Error if trying to use VFS on cores that don't support it

This commit is contained in:
krzys-h 2019-01-14 21:30:20 +01:00
parent 9188cc1a73
commit c8510378dc
7 changed files with 41 additions and 1 deletions

2
core.h
View File

@ -65,6 +65,8 @@ typedef struct rarch_system_info
const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY]; const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY];
char valid_extensions[255]; char valid_extensions[255];
bool supports_vfs;
struct retro_disk_control_callback disk_control_cb; struct retro_disk_control_callback disk_control_cb;
struct retro_location_callback location_cb; struct retro_location_callback location_cb;

View File

@ -1960,6 +1960,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
RARCH_LOG("Core requested VFS version >= v%d, providing v%d\n", vfs_iface_info->required_interface_version, supported_vfs_version); RARCH_LOG("Core requested VFS version >= v%d, providing v%d\n", vfs_iface_info->required_interface_version, supported_vfs_version);
vfs_iface_info->required_interface_version = supported_vfs_version; vfs_iface_info->required_interface_version = supported_vfs_version;
vfs_iface_info->iface = &vfs_iface; vfs_iface_info->iface = &vfs_iface;
system->supports_vfs = true;
} }
else else
{ {

View File

@ -4143,6 +4143,10 @@ MSG_HASH(
MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT, MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT,
"Libretro core requires special content, but none were provided." "Libretro core requires special content, but none were provided."
) )
MSG_HASH(
MSG_ERROR_LIBRETRO_CORE_REQUIRES_VFS,
"Loading content from here requires VFS, but core does not support it"
)
MSG_HASH( MSG_HASH(
MSG_ERROR_PARSING_ARGUMENTS, MSG_ERROR_PARSING_ARGUMENTS,
"Error parsing arguments." "Error parsing arguments."

View File

@ -49,6 +49,7 @@ using namespace Windows::Storage::FileProperties;
#include <verbosity.h> #include <verbosity.h>
#include <string/stdstring.h> #include <string/stdstring.h>
#include <retro_environment.h> #include <retro_environment.h>
#include <uwp/uwp_func.h>
namespace namespace
{ {
@ -603,3 +604,14 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir)
free(rdir); free(rdir);
return 0; return 0;
} }
bool uwp_is_path_accessible_using_standard_io(char *path)
{
char *relative_path_abbrev = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
fill_pathname_abbreviate_special(relative_path_abbrev, path, PATH_MAX_LENGTH * sizeof(char));
bool result = strlen(relative_path_abbrev) >= 2 && (relative_path_abbrev[0] == ':' || relative_path_abbrev[0] == '~') && path_char_is_slash(relative_path_abbrev[1]);
free(relative_path_abbrev);
return result;
}

View File

@ -260,6 +260,7 @@ enum msg_hash_enums
MSG_COMPILED_AGAINST_API, MSG_COMPILED_AGAINST_API,
MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT, MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT,
MSG_ERROR_LIBRETRO_CORE_REQUIRES_CONTENT, MSG_ERROR_LIBRETRO_CORE_REQUIRES_CONTENT,
MSG_ERROR_LIBRETRO_CORE_REQUIRES_VFS,
MSG_SEVERAL_PATCHES_ARE_EXPLICITLY_DEFINED, MSG_SEVERAL_PATCHES_ARE_EXPLICITLY_DEFINED,
MSG_DID_NOT_FIND_A_VALID_CONTENT_PATCH, MSG_DID_NOT_FIND_A_VALID_CONTENT_PATCH,
MSG_FAILED_TO_ALLOCATE_MEMORY_FOR_PATCHED_CONTENT, MSG_FAILED_TO_ALLOCATE_MEMORY_FOR_PATCHED_CONTENT,

View File

@ -39,6 +39,10 @@
#endif #endif
#endif #endif
#ifdef __WINRT__
#include <uwp/uwp_func.h>
#endif
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../config.h" #include "../config.h"
#endif #endif
@ -557,6 +561,7 @@ static bool content_file_load(
retro_ctx_load_content_info_t load_info; retro_ctx_load_content_info_t load_info;
size_t msg_size = 1024 * sizeof(char); size_t msg_size = 1024 * sizeof(char);
char *msg = (char*)malloc(msg_size); char *msg = (char*)malloc(msg_size);
rarch_system_info_t *system = runloop_get_system_info();
msg[0] = '\0'; msg[0] = '\0';
@ -605,7 +610,6 @@ static bool content_file_load(
} }
else else
{ {
#ifdef HAVE_COMPRESSION #ifdef HAVE_COMPRESSION
if ( !content_ctx->block_extract if ( !content_ctx->block_extract
&& need_fullpath && need_fullpath
@ -617,6 +621,21 @@ static bool content_file_load(
error_string)) error_string))
goto error; goto error;
#endif #endif
#ifdef __WINRT__
/* TODO: When support for the 'actual' VFS is added, there will need to be some more logic here */
if (!system->supports_vfs && !uwp_is_path_accessible_using_standard_io(path))
{
strlcpy(msg,
msg_hash_to_str(MSG_ERROR_LIBRETRO_CORE_REQUIRES_VFS),
msg_size
);
*error_string = strdup(msg);
goto error;
}
#endif
RARCH_LOG("%s\n", msg_hash_to_str(MSG_CONTENT_LOADING_SKIPPED_IMPLEMENTATION_WILL_DO_IT)); RARCH_LOG("%s\n", msg_hash_to_str(MSG_CONTENT_LOADING_SKIPPED_IMPLEMENTATION_WILL_DO_IT));
content_rom_crc = file_crc32(0, path); content_rom_crc = file_crc32(0, path);
RARCH_LOG("CRC32: 0x%x .\n", (unsigned)content_rom_crc); RARCH_LOG("CRC32: 0x%x .\n", (unsigned)content_rom_crc);

View File

@ -27,6 +27,7 @@ extern char uwp_dir_data[PATH_MAX_LENGTH];
extern char uwp_device_family[128]; extern char uwp_device_family[128];
void uwp_open_broadfilesystemaccess_settings(void); void uwp_open_broadfilesystemaccess_settings(void);
bool uwp_is_path_accessible_using_standard_io(char *path);
void* uwp_get_corewindow(void); void* uwp_get_corewindow(void);