Skip to content

Commit

Permalink
(UWP) Error if trying to use VFS on cores that don't support it
Browse files Browse the repository at this point in the history
  • Loading branch information
krzys-h committed Jan 17, 2019
1 parent 9188cc1 commit c851037
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 4 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
12 changes: 12 additions & 0 deletions libretro-common/vfs/vfs_implementation_uwp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ using namespace Windows::Storage::FileProperties;
#include <verbosity.h>
#include <string/stdstring.h>
#include <retro_environment.h>
#include <uwp/uwp_func.h>

namespace
{
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 20 additions & 1 deletion tasks/task_content.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#endif
#endif

#ifdef __WINRT__
#include <uwp/uwp_func.h>
#endif

#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -605,7 +610,6 @@ static bool content_file_load(
}
else
{

#ifdef HAVE_COMPRESSION
if ( !content_ctx->block_extract
&& need_fullpath
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions uwp/uwp_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c851037

Please sign in to comment.