From 64e154da9d0136793084080dbbd01fc7de3b0f2c Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 5 Dec 2024 22:55:05 -0800 Subject: [PATCH] Always use CreateFile2 --- Auxiliary/DirectXTexEXR.cpp | 25 ------------------- Auxiliary/DirectXTexXboxDDS.cpp | 32 ++++++++++--------------- CMakePresets.json | 18 +++++++------- DDSTextureLoader/DDSTextureLoader11.cpp | 10 -------- DDSTextureLoader/DDSTextureLoader9.cpp | 18 +++----------- DirectXTex/DirectXTexDDS.cpp | 28 ++++++++-------------- DirectXTex/DirectXTexHDR.cpp | 28 ++++++++-------------- DirectXTex/DirectXTexTGA.cpp | 31 ++++++++++-------------- ScreenGrab/ScreenGrab11.cpp | 11 ++++----- ScreenGrab/ScreenGrab12.cpp | 5 +++- ScreenGrab/ScreenGrab9.cpp | 11 ++++----- Texconv/ExtendedBMP.cpp | 10 ++++---- Texconv/PortablePixMap.cpp | 32 ++++++++++--------------- 13 files changed, 84 insertions(+), 175 deletions(-) diff --git a/Auxiliary/DirectXTexEXR.cpp b/Auxiliary/DirectXTexEXR.cpp index 09a6e2ee..e95b8598 100644 --- a/Auxiliary/DirectXTexEXR.cpp +++ b/Auxiliary/DirectXTexEXR.cpp @@ -240,19 +240,10 @@ HRESULT DirectX::GetMetadataFromEXRFile(const wchar_t* szFile, TexMetadata& meta } } -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2( szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW( - szFile, - GENERIC_READ, FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, - nullptr))); -#endif if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -358,19 +349,10 @@ HRESULT DirectX::LoadFromEXRFile(const wchar_t* szFile, TexMetadata* metadata, S } } -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2( szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW( - szFile, - GENERIC_READ, FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, - nullptr))); -#endif if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -508,19 +490,12 @@ HRESULT DirectX::SaveToEXRFile(const Image& image, const wchar_t* szFile) } // Create file and write header -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2( - szFile, - GENERIC_WRITE, 0, CREATE_ALWAYS, - nullptr))); -#else ScopedHandle hFile(safe_handle(CreateFileW( szFile, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/Auxiliary/DirectXTexXboxDDS.cpp b/Auxiliary/DirectXTexXboxDDS.cpp index 07495195..d573485e 100644 --- a/Auxiliary/DirectXTexXboxDDS.cpp +++ b/Auxiliary/DirectXTexXboxDDS.cpp @@ -439,12 +439,10 @@ HRESULT Xbox::GetMetadataFromDDSFileEx( isXbox = false; -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -591,13 +589,10 @@ HRESULT Xbox::LoadFromDDSFileEx( xbox.Release(); -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif - + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -742,13 +737,10 @@ HRESULT Xbox::SaveToDDSFile(const XboxImage& xbox, const wchar_t* szFile) return hr; // Create file and write header -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_WRITE, 0, CREATE_ALWAYS, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/CMakePresets.json b/CMakePresets.json index bf264c1e..1409fafe 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -118,7 +118,7 @@ }, { - "name": "Win7", + "name": "Win8", "cacheVariables": { "BUILD_DX12": false }, @@ -294,10 +294,10 @@ { "name": "arm64-Debug-UWP" , "description": "MSVC for ARM64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "MSVC", "UWP" ] }, { "name": "arm64-Release-UWP", "description": "MSVC for ARM64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "MSVC", "UWP" ] }, - { "name": "x64-Debug-Win7" , "description": "MSVC for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "MSVC", "Win7" ] }, - { "name": "x64-Release-Win7" , "description": "MSVC for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "MSVC", "Win7" ] }, - { "name": "x86-Debug-Win7" , "description": "MSVC for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "MSVC", "Win7" ] }, - { "name": "x86-Release-Win7" , "description": "MSVC for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "MSVC", "Win7" ] }, + { "name": "x64-Debug-Win8" , "description": "MSVC for x64 (Debug) for Windows 8.1", "inherits": [ "base", "x64", "Debug", "MSVC", "Win8" ] }, + { "name": "x64-Release-Win8" , "description": "MSVC for x64 (Release) for Windows 8.1", "inherits": [ "base", "x64", "Release", "MSVC", "Win8" ] }, + { "name": "x86-Debug-Win8" , "description": "MSVC for x86 (Debug) for Windows 8.1", "inherits": [ "base", "x86", "Debug", "MSVC", "Win8" ] }, + { "name": "x86-Release-Win8" , "description": "MSVC for x86 (Release) for Windows 8.1", "inherits": [ "base", "x86", "Release", "MSVC", "Win8" ] }, { "name": "x64-Debug-Scarlett" , "description": "MSVC for x64 (Debug) for Xbox Series X|S", "inherits": [ "base", "x64", "Debug", "MSVC", "Scarlett" ] }, { "name": "x64-Release-Scarlett" , "description": "MSVC for x64 (Release) for Xbox Series X|S", "inherits": [ "base", "x64", "Release", "MSVC", "Scarlett" ] }, @@ -337,10 +337,10 @@ { "name": "arm64-Debug-UWP-Clang" , "description": "Clang/LLVM for AArch64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "Clang", "Clang-AArch64", "UWP" ] }, { "name": "arm64-Release-UWP-Clang", "description": "Clang/LLVM for AArch64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "Clang", "Clang-AArch64", "UWP" ] }, - { "name": "x64-Debug-Win7-Clang" , "description": "Clang/LLVM for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "Clang", "Win7" ] }, - { "name": "x64-Release-Win7-Clang", "description": "Clang/LLVM for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "Clang", "Win7" ] }, - { "name": "x86-Debug-Win7-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "Clang", "Clang-X86", "Win7" ] }, - { "name": "x86-Release-Win7-Clang", "description": "Clang/LLVM for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "Clang", "Clang-X86", "Win7" ] }, + { "name": "x64-Debug-Win8-Clang" , "description": "Clang/LLVM for x64 (Debug) for Windows 8.1", "inherits": [ "base", "x64", "Debug", "Clang", "Win8" ] }, + { "name": "x64-Release-Win8-Clang", "description": "Clang/LLVM for x64 (Release) for Windows 8.1", "inherits": [ "base", "x64", "Release", "Clang", "Win8" ] }, + { "name": "x86-Debug-Win8-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 8.1", "inherits": [ "base", "x86", "Debug", "Clang", "Clang-X86", "Win8" ] }, + { "name": "x86-Release-Win8-Clang", "description": "Clang/LLVM for x86 (Release) for Windows 8.1", "inherits": [ "base", "x86", "Release", "Clang", "Clang-X86", "Win8" ] }, { "name": "x64-Debug-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Debug) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Debug", "Clang", "VCPKG" ] }, { "name": "x64-Release-Clang-VCPKG" , "description": "Clang/LLVM for x64 (Release) using VCPKG/OpenEXR", "inherits": [ "base", "x64", "Release", "Clang", "VCPKG" ] }, diff --git a/DDSTextureLoader/DDSTextureLoader11.cpp b/DDSTextureLoader/DDSTextureLoader11.cpp index 50d16413..e32afbd7 100644 --- a/DDSTextureLoader/DDSTextureLoader11.cpp +++ b/DDSTextureLoader/DDSTextureLoader11.cpp @@ -239,20 +239,10 @@ namespace *bitSize = 0; // open the file - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2( fileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW( - fileName, - GENERIC_READ, FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - nullptr))); - #endif - if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/DDSTextureLoader/DDSTextureLoader9.cpp b/DDSTextureLoader/DDSTextureLoader9.cpp index 92f17fc9..aa738133 100644 --- a/DDSTextureLoader/DDSTextureLoader9.cpp +++ b/DDSTextureLoader/DDSTextureLoader9.cpp @@ -204,22 +204,10 @@ namespace *bitSize = 0; // open the file - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, + ScopedHandle hFile(safe_handle(CreateFile2( + fileName, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW(fileName, - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr))); - #endif - if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index c471da3c..e2f99269 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -1878,12 +1878,10 @@ HRESULT DirectX::GetMetadataFromDDSFileEx( return E_INVALIDARG; #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2064,12 +2062,10 @@ HRESULT DirectX::LoadFromDDSFileEx( image.Release(); #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2548,13 +2544,9 @@ HRESULT DirectX::SaveToDDSFile( // Create file and write header #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/DirectXTex/DirectXTexHDR.cpp b/DirectXTex/DirectXTexHDR.cpp index 7c8bd08d..75c5faf0 100644 --- a/DirectXTex/DirectXTexHDR.cpp +++ b/DirectXTex/DirectXTexHDR.cpp @@ -617,12 +617,10 @@ HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& meta return E_INVALIDARG; #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -921,12 +919,10 @@ HRESULT DirectX::LoadFromHDRFile(const wchar_t* szFile, TexMetadata* metadata, S image.Release(); #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -1144,13 +1140,9 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce // Create file and write header #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/DirectXTex/DirectXTexTGA.cpp b/DirectXTex/DirectXTexTGA.cpp index b758a4f8..2390ee00 100644 --- a/DirectXTex/DirectXTexTGA.cpp +++ b/DirectXTex/DirectXTexTGA.cpp @@ -1492,12 +1492,10 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags, return E_INVALIDARG; #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -1758,12 +1756,10 @@ HRESULT DirectX::LoadFromTGAFile( image.Release(); #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2357,13 +2353,10 @@ HRESULT DirectX::SaveToTGAFile( // Create file and write header #ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_WRITE, 0, - CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_WRITE, 0, CREATE_ALWAYS, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/ScreenGrab/ScreenGrab11.cpp b/ScreenGrab/ScreenGrab11.cpp index 313e2b2e..236201e2 100644 --- a/ScreenGrab/ScreenGrab11.cpp +++ b/ScreenGrab/ScreenGrab11.cpp @@ -803,13 +803,10 @@ HRESULT DirectX::SaveDDSTextureToFile( return hr; // Create file -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(fileName, - GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + fileName, + GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, + nullptr))); if (!hFile) return HRESULT_FROM_WIN32(GetLastError()); diff --git a/ScreenGrab/ScreenGrab12.cpp b/ScreenGrab/ScreenGrab12.cpp index b8cd697f..7ce04ff3 100644 --- a/ScreenGrab/ScreenGrab12.cpp +++ b/ScreenGrab/ScreenGrab12.cpp @@ -967,7 +967,10 @@ HRESULT DirectX::SaveDDSTextureToFile( // Create file #ifdef _WIN32 - ScopedHandle hFile(safe_handle(CreateFile2(fileName, GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); + ScopedHandle hFile(safe_handle(CreateFile2( + fileName, + GENERIC_WRITE, 0, CREATE_ALWAYS, + nullptr))); if (!hFile) return HRESULT_FROM_WIN32(GetLastError()); diff --git a/ScreenGrab/ScreenGrab9.cpp b/ScreenGrab/ScreenGrab9.cpp index afde861e..3977cf30 100644 --- a/ScreenGrab/ScreenGrab9.cpp +++ b/ScreenGrab/ScreenGrab9.cpp @@ -590,13 +590,10 @@ HRESULT DirectX::SaveDDSTextureToFile( } // Create file -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(fileName, - GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + fileName, + GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, + nullptr))); if (!hFile) return HRESULT_FROM_WIN32(GetLastError()); diff --git a/Texconv/ExtendedBMP.cpp b/Texconv/ExtendedBMP.cpp index 6b5acedc..6edb9dcf 100644 --- a/Texconv/ExtendedBMP.cpp +++ b/Texconv/ExtendedBMP.cpp @@ -49,12 +49,10 @@ namespace { blob.reset(); - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); - #endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); diff --git a/Texconv/PortablePixMap.cpp b/Texconv/PortablePixMap.cpp index f293280a..c1764d0a 100644 --- a/Texconv/PortablePixMap.cpp +++ b/Texconv/PortablePixMap.cpp @@ -91,12 +91,10 @@ namespace blob.reset(); - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); - #endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, + nullptr))); if (!hFile) { return HRESULT_FROM_WIN32(GetLastError()); @@ -423,13 +421,10 @@ HRESULT __cdecl SaveToPortablePixMap( } } -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_WRITE, 0, CREATE_ALWAYS, + nullptr))); if (!hFile) return HRESULT_FROM_WIN32(GetLastError()); @@ -741,13 +736,10 @@ HRESULT __cdecl SaveToPortablePixMapHDR( tmpImage.Release(); -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif + ScopedHandle hFile(safe_handle(CreateFile2( + szFile, + GENERIC_WRITE, 0, CREATE_ALWAYS, + nullptr))); if (!hFile) return HRESULT_FROM_WIN32(GetLastError());