diff --git a/libretro-common/vfs/vfs_implementation_uwp.cpp b/libretro-common/vfs/vfs_implementation_uwp.cpp index 3f844c842f..dac09ddf62 100644 --- a/libretro-common/vfs/vfs_implementation_uwp.cpp +++ b/libretro-common/vfs/vfs_implementation_uwp.cpp @@ -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) { - if (!stream || (!stream->fp && stream->fh == INVALID_HANDLE_VALUE)) + if (!stream) 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) { - return ftell(stream->fp); + return _ftelli64(stream->fp); } if (lseek(stream->fd, 0, SEEK_CUR) < 0) return -1; diff --git a/tasks/task_content.c b/tasks/task_content.c index 72e3f539d6..4cff506808 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -38,6 +38,7 @@ #endif #ifdef __WINRT__ +#include #include #endif @@ -1047,8 +1048,6 @@ static bool content_file_load( !is_path_accessible_using_standard_io(content_path)) { /* Fallback to a file copy into an accessible directory */ - char *buf; - int64_t len; char new_basedir[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, 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... - * but copying large files is not a good idea anyway */ - if (!filestream_read_file(content_path, &buf, &len)) + * but copying large files is not a good idea anyway + * (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), content_path); *error_string = strdup(msg); 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( p_content->content_list, new_path);