From bb0fe6c2d16c979fb560da77f95ce567cac13e00 Mon Sep 17 00:00:00 2001 From: Tunip3 Date: Thu, 26 Aug 2021 23:18:42 +0100 Subject: [PATCH] fix extraction issues --- .../vfs/vfs_implementation_uwp.cpp | 20 +++++++++++-------- uwp/uwp_func.h | 1 - 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libretro-common/vfs/vfs_implementation_uwp.cpp b/libretro-common/vfs/vfs_implementation_uwp.cpp index cdcdf33fd2..bfd20cb2d3 100644 --- a/libretro-common/vfs/vfs_implementation_uwp.cpp +++ b/libretro-common/vfs/vfs_implementation_uwp.cpp @@ -384,15 +384,15 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( /* Try Win32 first, this should work in AppData */ switch (mode) { - case RETRO_VFS_FILE_ACCESS_READ: - desireAccess = GENERIC_READ; - break; - case RETRO_VFS_FILE_ACCESS_WRITE: - desireAccess = GENERIC_READ; - break; case RETRO_VFS_FILE_ACCESS_READ_WRITE: desireAccess = GENERIC_READ | GENERIC_WRITE; break; + case RETRO_VFS_FILE_ACCESS_WRITE: + desireAccess = GENERIC_WRITE; + break; + case RETRO_VFS_FILE_ACCESS_READ: + desireAccess = GENERIC_READ; + break; } if (mode == RETRO_VFS_FILE_ACCESS_READ) { @@ -401,7 +401,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( else { creationDisposition = (mode & RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING) != 0 ? - OPEN_ALWAYS : CREATE_ALWAYS; + OPEN_ALWAYS : CREATE_ALWAYS; } file_handle = CreateFile2FromAppW(path_str->Data(), desireAccess, FILE_SHARE_READ, creationDisposition, NULL); @@ -685,6 +685,7 @@ int retro_vfs_file_remove_impl(const char *path) /* Try Win32 first, this should work in AppData */ result = DeleteFileFromAppW(path_wide); + free(path_wide); if (result) return 0; @@ -850,6 +851,7 @@ int uwp_copy_acl(const wchar_t* source, const wchar_t* target) int uwp_mkdir_impl(std::experimental::filesystem::path dir) { //I feel like this should create the directory recursively but the existing implementation does not so this update won't + //I put in the work but I just commented out the stuff you would need WIN32_FILE_ATTRIBUTE_DATA lpFileInfo; bool parent_dir_exists = false; @@ -872,7 +874,7 @@ int uwp_mkdir_impl(std::experimental::filesystem::path dir) { //try to create parent dir int success = uwp_mkdir_impl(dir.parent_path()); - if (success != 0 || success != -2) + if (success != 0 && success != -2) return success; } @@ -1089,9 +1091,11 @@ int retro_vfs_stat_impl(const char *path, int32_t *size) *size = sz.QuadPart; } } + free(path_wide); return (attribdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? RETRO_VFS_STAT_IS_VALID | RETRO_VFS_STAT_IS_DIRECTORY : RETRO_VFS_STAT_IS_VALID; } } + free(path_wide); return 0; } diff --git a/uwp/uwp_func.h b/uwp/uwp_func.h index 87bd3adeab..d0579f269d 100644 --- a/uwp/uwp_func.h +++ b/uwp/uwp_func.h @@ -27,7 +27,6 @@ extern char uwp_dir_data[PATH_MAX_LENGTH]; extern char uwp_device_family[128]; void uwp_open_broadfilesystemaccess_settings(void); -bool uwp_drive_exists(const char *path); char* uwp_trigger_picker(void); void* uwp_get_corewindow(void);