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

Steve Lhomme robux4 at ycbcr.xyz
Thu Apr 30 12:22:02 CEST 2020


- CreateFile2 where CreateFileW is used
- GetFileInformationByHandleEx instead of GetFileSize (which is what winstore
  compat did)
---
 contrib/src/taglib/rules.mak                 |  4 +-
 contrib/src/taglib/taglib-winstore-fix.patch | 39 ++++++++++++++++++++
 contrib/src/taglib/unicode.patch             | 13 -------
 3 files changed, 40 insertions(+), 16 deletions(-)
 create mode 100644 contrib/src/taglib/taglib-winstore-fix.patch
 delete mode 100644 contrib/src/taglib/unicode.patch

diff --git a/contrib/src/taglib/rules.mak b/contrib/src/taglib/rules.mak
index ba7db32c5e9..2960c90aa3a 100644
--- a/contrib/src/taglib/rules.mak
+++ b/contrib/src/taglib/rules.mak
@@ -15,9 +15,7 @@ $(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/taglib-winstore-fix.patch
 	$(APPLY) $(SRC)/taglib/use_resolvers_on_streams.patch
 	$(MOVE)
 
diff --git a/contrib/src/taglib/taglib-winstore-fix.patch b/contrib/src/taglib/taglib-winstore-fix.patch
new file mode 100644
index 00000000000..9ad95a07d95
--- /dev/null
+++ b/contrib/src/taglib/taglib-winstore-fix.patch
@@ -0,0 +1,39 @@
+--- taglib/taglib/toolkit/tfilestream.cpp.winapi	2020-04-28 15:12:56.509601900 +0200
++++ taglib/taglib/toolkit/tfilestream.cpp	2020-04-28 15:12:28.437698700 +0200
+@@ -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_APP)
++    {
++      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;
+   }
+@@ -437,9 +450,10 @@ long FileStream::length()
+ #ifdef _WIN32
+ 
+   SetLastError(NO_ERROR);
+-  const DWORD fileSize = GetFileSize(d->file, NULL);
+-  if(GetLastError() == NO_ERROR) {
+-    return static_cast<long>(fileSize);
++  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);
+   }
+   else {
+     debug("FileStream::length() -- Failed to get the file size.");
diff --git a/contrib/src/taglib/unicode.patch b/contrib/src/taglib/unicode.patch
deleted file mode 100644
index 954ad64045c..00000000000
--- 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;
-   }
-- 
2.17.1



More information about the vlc-devel mailing list