mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
Fix roms over 4gb (approx) failing to load, improve copy times, fix scanning for playlists [UWP/XBOX] (#13348)
* Fix scanning for playlists * Fix issues where games over 4gb (approx) would fail to load and also speed up loading times
This commit is contained in:
parent
6870f0114e
commit
62528a483f
@ -158,19 +158,12 @@ int64_t retro_vfs_file_truncate_impl(libretro_vfs_implementation_file* stream, i
|
|||||||
|
|
||||||
int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file* stream)
|
int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file* stream)
|
||||||
{
|
{
|
||||||
if (!stream || (!stream->fp && stream->fh == INVALID_HANDLE_VALUE))
|
if (!stream)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (stream->fh != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
LARGE_INTEGER sz;
|
|
||||||
if (GetFileSizeEx(stream->fh, &sz))
|
|
||||||
return sz.QuadPart;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
{
|
{
|
||||||
return ftell(stream->fp);
|
return _ftelli64(stream->fp);
|
||||||
}
|
}
|
||||||
if (lseek(stream->fd, 0, SEEK_CUR) < 0)
|
if (lseek(stream->fd, 0, SEEK_CUR) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WINRT__
|
#ifdef __WINRT__
|
||||||
|
#include <Fileapifromapp.h>
|
||||||
#include <uwp/uwp_func.h>
|
#include <uwp/uwp_func.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1047,8 +1048,6 @@ static bool content_file_load(
|
|||||||
!is_path_accessible_using_standard_io(content_path))
|
!is_path_accessible_using_standard_io(content_path))
|
||||||
{
|
{
|
||||||
/* Fallback to a file copy into an accessible directory */
|
/* Fallback to a file copy into an accessible directory */
|
||||||
char *buf;
|
|
||||||
int64_t len;
|
|
||||||
char new_basedir[PATH_MAX_LENGTH];
|
char new_basedir[PATH_MAX_LENGTH];
|
||||||
char new_path[PATH_MAX_LENGTH];
|
char new_path[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
@ -1075,29 +1074,23 @@ static bool content_file_load(
|
|||||||
fill_pathname_join(new_path, new_basedir,
|
fill_pathname_join(new_path, new_basedir,
|
||||||
path_basename(content_path), sizeof(new_path));
|
path_basename(content_path), sizeof(new_path));
|
||||||
|
|
||||||
|
wchar_t wcontent_path[MAX_PATH];
|
||||||
|
mbstowcs(wcontent_path, content_path, MAX_PATH);
|
||||||
|
wchar_t wnew_path[MAX_PATH];
|
||||||
|
mbstowcs(wnew_path, new_path, MAX_PATH);
|
||||||
/* TODO: This may fail on very large files...
|
/* TODO: This may fail on very large files...
|
||||||
* but copying large files is not a good idea anyway */
|
* but copying large files is not a good idea anyway
|
||||||
if (!filestream_read_file(content_path, &buf, &len))
|
* (This disclaimer is out dated but I don't want to remove it)*/
|
||||||
|
if (!CopyFileFromAppW(wcontent_path,wnew_path,false))
|
||||||
{
|
{
|
||||||
snprintf(msg, sizeof(msg), "%s \"%s\". (during copy read)\n",
|
int err = GetLastError();
|
||||||
|
snprintf(msg, sizeof(msg), "%s \"%s\". (during copy read or write)\n",
|
||||||
msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE),
|
msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE),
|
||||||
content_path);
|
content_path);
|
||||||
*error_string = strdup(msg);
|
*error_string = strdup(msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filestream_write_file(new_path, buf, len))
|
|
||||||
{
|
|
||||||
free(buf);
|
|
||||||
snprintf(msg, sizeof(msg), "%s \"%s\". (during copy write)\n",
|
|
||||||
msg_hash_to_str(MSG_COULD_NOT_READ_CONTENT_FILE),
|
|
||||||
content_path);
|
|
||||||
*error_string = strdup(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(buf);
|
|
||||||
|
|
||||||
content_path = content_file_list_append_temporary(
|
content_path = content_file_list_append_temporary(
|
||||||
p_content->content_list, new_path);
|
p_content->content_list, new_path);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user