Merge pull request #12721 from Xbox-Homebrew/master

replace win32 functions with UWP safe variants in UWP vfs driver
This commit is contained in:
Autechre 2021-07-31 21:01:46 +02:00 committed by GitHub
commit 8b1e816f77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 18 deletions

1
.gitignore vendored
View File

@ -223,3 +223,4 @@ param.sfo
*.elf
*.self
*.vpk
/.vs

View File

@ -31,6 +31,7 @@
#include <robuffer.h>
#include <collection.h>
#include <functional>
#include <fileapifromapp.h>
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
@ -388,7 +389,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
OPEN_ALWAYS : CREATE_ALWAYS;
}
file_handle = CreateFile2(path_str->Data(), desireAccess, FILE_SHARE_READ, creationDisposition, NULL);
file_handle = CreateFile2FromAppW(path_str->Data(), desireAccess, FILE_SHARE_READ, creationDisposition, NULL);
if (file_handle != INVALID_HANDLE_VALUE)
{
@ -744,7 +745,7 @@ int retro_vfs_file_remove_impl(const char *path)
free(path_wide);
/* Try Win32 first, this should work in AppData */
result = DeleteFileW(path_str->Data());
result = DeleteFileFromAppW(path_str->Data());
if (result)
return 0;
@ -827,6 +828,7 @@ int retro_vfs_stat_impl(const char *path, int32_t *size)
Platform::String^ path_str;
IStorageItem^ item;
DWORD file_info;
_WIN32_FILE_ATTRIBUTE_DATA attribdata;
if (!path || !*path)
return 0;
@ -837,21 +839,22 @@ int retro_vfs_stat_impl(const char *path, int32_t *size)
free(path_wide);
/* Try Win32 first, this should work in AppData */
file_info = GetFileAttributesW(path_str->Data());
if (file_info != INVALID_FILE_ATTRIBUTES)
if (GetFileAttributesExFromAppW(path_str->Data(), GetFileExInfoStandard, &attribdata))
{
HANDLE file_handle = CreateFile2(path_str->Data(), GENERIC_READ, FILE_SHARE_READ, OPEN_ALWAYS, NULL);
if (file_handle != INVALID_HANDLE_VALUE)
{
LARGE_INTEGER sz;
if (GetFileSizeEx(file_handle, &sz))
{
if (size)
*size = sz.QuadPart;
}
CloseHandle(file_handle);
}
return (file_info & FILE_ATTRIBUTE_DIRECTORY) ? RETRO_VFS_STAT_IS_VALID | RETRO_VFS_STAT_IS_DIRECTORY : RETRO_VFS_STAT_IS_VALID;
file_info = attribdata.dwFileAttributes;
if (file_info != INVALID_FILE_ATTRIBUTES)
{
if (!(file_info & FILE_ATTRIBUTE_DIRECTORY))
{
LARGE_INTEGER sz;
if (size)
{
sz.HighPart = attribdata.nFileSizeHigh;
sz.LowPart = attribdata.nFileSizeLow;
}
}
return (file_info & FILE_ATTRIBUTE_DIRECTORY) ? RETRO_VFS_STAT_IS_VALID | RETRO_VFS_STAT_IS_DIRECTORY : RETRO_VFS_STAT_IS_VALID;
}
}
if (GetLastError() == ERROR_FILE_NOT_FOUND)
@ -917,7 +920,7 @@ int retro_vfs_mkdir_impl(const char *dir)
free(dir_local);
/* Try Win32 first, this should work in AppData */
result = CreateDirectoryW(dir_str->Data(), NULL);
result = CreateDirectoryFromAppW(dir_str->Data(), NULL);
if (result)
return 0;

View File

@ -232,11 +232,12 @@
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
<AppxBundle>Always</AppxBundle>
<PackageCertificateThumbprint>B86DAF5EC706754FEBABD0B011B0C4C3C2F73251</PackageCertificateThumbprint>
<PackageCertificateThumbprint>261A18AB51F9C1DC1956AF9084285F82A2A7FD30</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<PackageCertificateKeyFile>RetroArch-msvc2019-UWP_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<Link>