diff --git a/core.h b/core.h index 06cdbac698..40d0a193d4 100644 --- a/core.h +++ b/core.h @@ -65,6 +65,8 @@ typedef struct rarch_system_info const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY]; char valid_extensions[255]; + bool supports_vfs; + struct retro_disk_control_callback disk_control_cb; struct retro_location_callback location_cb; diff --git a/dynamic.c b/dynamic.c index a6d3074013..eceba94e22 100644 --- a/dynamic.c +++ b/dynamic.c @@ -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); vfs_iface_info->required_interface_version = supported_vfs_version; vfs_iface_info->iface = &vfs_iface; + system->supports_vfs = true; } else { diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 6fc52c51ca..6b1323e3a8 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -4143,6 +4143,10 @@ MSG_HASH( MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT, "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_ERROR_PARSING_ARGUMENTS, "Error parsing arguments." diff --git a/libretro-common/vfs/vfs_implementation_uwp.cpp b/libretro-common/vfs/vfs_implementation_uwp.cpp index 5293a13f41..b1eee0cf0a 100644 --- a/libretro-common/vfs/vfs_implementation_uwp.cpp +++ b/libretro-common/vfs/vfs_implementation_uwp.cpp @@ -49,6 +49,7 @@ using namespace Windows::Storage::FileProperties; #include #include #include +#include namespace { @@ -603,3 +604,14 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir) free(rdir); 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; +} diff --git a/msg_hash.h b/msg_hash.h index c6501869d3..7f87dfba60 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -260,6 +260,7 @@ enum msg_hash_enums MSG_COMPILED_AGAINST_API, MSG_ERROR_LIBRETRO_CORE_REQUIRES_SPECIAL_CONTENT, MSG_ERROR_LIBRETRO_CORE_REQUIRES_CONTENT, + MSG_ERROR_LIBRETRO_CORE_REQUIRES_VFS, MSG_SEVERAL_PATCHES_ARE_EXPLICITLY_DEFINED, MSG_DID_NOT_FIND_A_VALID_CONTENT_PATCH, MSG_FAILED_TO_ALLOCATE_MEMORY_FOR_PATCHED_CONTENT, diff --git a/tasks/task_content.c b/tasks/task_content.c index 3445f69383..dee66b7cd8 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -39,6 +39,10 @@ #endif #endif +#ifdef __WINRT__ +#include +#endif + #ifdef HAVE_CONFIG_H #include "../config.h" #endif @@ -557,6 +561,7 @@ static bool content_file_load( retro_ctx_load_content_info_t load_info; size_t msg_size = 1024 * sizeof(char); char *msg = (char*)malloc(msg_size); + rarch_system_info_t *system = runloop_get_system_info(); msg[0] = '\0'; @@ -605,7 +610,6 @@ static bool content_file_load( } else { - #ifdef HAVE_COMPRESSION if ( !content_ctx->block_extract && need_fullpath @@ -617,6 +621,21 @@ static bool content_file_load( error_string)) goto error; #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)); content_rom_crc = file_crc32(0, path); RARCH_LOG("CRC32: 0x%x .\n", (unsigned)content_rom_crc); diff --git a/uwp/uwp_func.h b/uwp/uwp_func.h index 65e663d3de..d137909c04 100644 --- a/uwp/uwp_func.h +++ b/uwp/uwp_func.h @@ -27,6 +27,7 @@ extern char uwp_dir_data[PATH_MAX_LENGTH]; extern char uwp_device_family[128]; void uwp_open_broadfilesystemaccess_settings(void); +bool uwp_is_path_accessible_using_standard_io(char *path); void* uwp_get_corewindow(void);