[vlc-commits] contrib: taglib: only use APIs in winstore builds

Steve Lhomme git at videolan.org
Fri Jun 19 09:06:46 CEST 2020


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Apr 28 12:49:27 2020 +0200| [3d7301f605e9c8cc097dcc3cb7c73ad6b39cd1de] | committer: Steve Lhomme

contrib: taglib: only use APIs in winstore builds

- CreateFile2 where CreateFileW is used
- GetFileInformationByHandleEx instead of GetFileSize (which is what winstore
  compat did)

(cherry picked from commit 1730fe70e72ff41c6ca3cc78befc30142db8ec4f)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=3d7301f605e9c8cc097dcc3cb7c73ad6b39cd1de
---

 ...InformationByHandleEx-on-newer-builds-of-.patch | 39 ++++++++++++++++++++
 .../0003-don-t-use-CreateFile-in-UWP-builds.patch  | 43 ++++++++++++++++++++++
 contrib/src/taglib/rules.mak                       |  5 +--
 contrib/src/taglib/unicode.patch                   | 13 -------
 4 files changed, 84 insertions(+), 16 deletions(-)

diff --git a/contrib/src/taglib/0002-use-GetFileInformationByHandleEx-on-newer-builds-of-.patch b/contrib/src/taglib/0002-use-GetFileInformationByHandleEx-on-newer-builds-of-.patch
new file mode 100644
index 0000000000..5519d5e21f
--- /dev/null
+++ b/contrib/src/taglib/0002-use-GetFileInformationByHandleEx-on-newer-builds-of-.patch
@@ -0,0 +1,39 @@
+From 9c02a2c245bed1d70dbd80b0e63abbcdecb74761 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Fri, 15 May 2020 09:29:55 +0200
+Subject: [PATCH 2/3] use GetFileInformationByHandleEx on newer builds of
+ Windows
+
+It's available since Vista and UWP builds that don't have GetFileSize.
+
+See https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis
+---
+ taglib/toolkit/tfilestream.cpp | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp
+index 4b448271..ad4443ea 100644
+--- a/taglib/toolkit/tfilestream.cpp
++++ b/taglib/toolkit/tfilestream.cpp
+@@ -441,10 +441,18 @@ long FileStream::length()
+ #ifdef _WIN32
+ 
+   SetLastError(NO_ERROR);
++#if _WIN32_WINNT < _WIN32_WINNT_VISTA
+   const DWORD fileSize = GetFileSize(d->file, NULL);
+   if(GetLastError() == NO_ERROR) {
+     return static_cast<long>(fileSize);
+   }
++#else // _WIN32_WINNT_VISTA
++  FILE_STANDARD_INFO fStdInfo;
++  BOOL success = GetFileInformationByHandleEx(d->file, FileStandardInfo, (LPVOID)&fStdInfo, sizeof(FILE_STANDARD_INFO));
++  if(success) {
++    return static_cast<long>(fStdInfo.EndOfFile.LowPart);
++  }
++#endif // _WIN32_WINNT_VISTA
+   else {
+     debug("FileStream::length() -- Failed to get the file size.");
+     return 0;
+-- 
+2.26.0.windows.1
+
diff --git a/contrib/src/taglib/0003-don-t-use-CreateFile-in-UWP-builds.patch b/contrib/src/taglib/0003-don-t-use-CreateFile-in-UWP-builds.patch
new file mode 100644
index 0000000000..826eb9d056
--- /dev/null
+++ b/contrib/src/taglib/0003-don-t-use-CreateFile-in-UWP-builds.patch
@@ -0,0 +1,43 @@
+From a9024bd18ce20653616e04702b5e220de56b6b2c Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Fri, 15 May 2020 09:32:21 +0200
+Subject: [PATCH 3/3] don't use CreateFile in UWP builds
+
+CreateFile2 is available for such builds with more internal restrictions.
+
+See https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis
+https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfile2
+---
+ taglib/toolkit/tfilestream.cpp | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp
+index ad4443ea..10cd8d56 100644
+--- a/taglib/toolkit/tfilestream.cpp
++++ b/taglib/toolkit/tfilestream.cpp
+@@ -52,9 +52,22 @@ namespace
+     const DWORD access = readOnly ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE);
+ 
+     if(!path.wstr().empty())
++#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
++    {
++      CREATEFILE2_EXTENDED_PARAMETERS createExParams;
++      createExParams.dwSize = sizeof(createExParams);
++      createExParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
++      createExParams.dwFileFlags = 0;
++      createExParams.dwSecurityQosFlags = 0;
++      createExParams.lpSecurityAttributes = NULL;
++      createExParams.hTemplateFile = NULL;
++      return CreateFile2(path.wstr().c_str(), access, FILE_SHARE_READ, OPEN_EXISTING, &createExParams);
++    }
++#else // WINAPI_PARTITION_DESKTOP
+       return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+     else if(!path.str().empty())
+       return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
++#endif // WINAPI_PARTITION_DESKTOP
+     else
+       return InvalidFileHandle;
+   }
+-- 
+2.26.0.windows.1
+
diff --git a/contrib/src/taglib/rules.mak b/contrib/src/taglib/rules.mak
index ba7db32c5e..2844ed4d5d 100644
--- a/contrib/src/taglib/rules.mak
+++ b/contrib/src/taglib/rules.mak
@@ -15,9 +15,8 @@ $(TARBALLS)/taglib-$(TAGLIB_VERSION).tar.gz:
 
 taglib: taglib-$(TAGLIB_VERSION).tar.gz .sum-taglib
 	$(UNPACK)
-ifdef HAVE_WINSTORE
-	$(APPLY) $(SRC)/taglib/unicode.patch
-endif
+	$(APPLY) $(SRC)/taglib/0002-use-GetFileInformationByHandleEx-on-newer-builds-of-.patch
+	$(APPLY) $(SRC)/taglib/0003-don-t-use-CreateFile-in-UWP-builds.patch
 	$(APPLY) $(SRC)/taglib/use_resolvers_on_streams.patch
 	$(MOVE)
 
diff --git a/contrib/src/taglib/unicode.patch b/contrib/src/taglib/unicode.patch
deleted file mode 100644
index 954ad64045..0000000000
--- a/contrib/src/taglib/unicode.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- taglib/taglib/toolkit/tfilestream.cpp.orig	2016-04-07 15:14:47.251819871 +0200
-+++ taglib/taglib/toolkit/tfilestream.cpp	2016-04-07 15:15:05.491812493 +0200
-@@ -53,8 +53,10 @@
- 
-     if(!path.wstr().empty())
-       return CreateFileW(path.wstr().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
-+#ifndef UNICODE
-     else if(!path.str().empty())
-       return CreateFileA(path.str().c_str(), access, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
-+#endif
-     else
-       return InvalidFileHandle;
-   }



More information about the vlc-commits mailing list