Browse Source
fix #26309
(cherry picked from commit c651b10d33)
Signed-off-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
pull/135/head
6 changed files with 3 additions and 173 deletions
@ -1,40 +0,0 @@ |
|||
From d27cc3568c2c04e86a8ec6e29fcdf7e3814b0596 Mon Sep 17 00:00:00 2001 |
|||
From: Steve Lhomme <robux4@ycbcr.xyz> |
|||
Date: Fri, 15 May 2020 09:25:40 +0200 |
|||
Subject: [PATCH 1/3] use SetFilePointerEx instead of SetFilePointer |
|||
|
|||
It's available on more Win10 versions with UCRT builds and provides the same |
|||
features. The API is available since Windows XP. |
|||
---
|
|||
taglib/toolkit/tfilestream.cpp | 8 ++++++-- |
|||
1 file changed, 6 insertions(+), 2 deletions(-) |
|||
|
|||
diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp
|
|||
index 5205bae0..4b448271 100644
|
|||
--- a/taglib/toolkit/tfilestream.cpp
|
|||
+++ b/taglib/toolkit/tfilestream.cpp
|
|||
@@ -364,7 +364,9 @@ void FileStream::seek(long offset, Position p)
|
|||
} |
|||
|
|||
SetLastError(NO_ERROR); |
|||
- SetFilePointer(d->file, offset, NULL, whence);
|
|||
+ LARGE_INTEGER lOffset;
|
|||
+ lOffset.QuadPart = offset;
|
|||
+ SetFilePointerEx(d->file, lOffset, NULL, whence);
|
|||
|
|||
const int lastError = GetLastError(); |
|||
if(lastError != NO_ERROR && lastError != ERROR_NEGATIVE_SEEK) |
|||
@@ -411,7 +413,9 @@ long FileStream::tell() const
|
|||
#ifdef _WIN32 |
|||
|
|||
SetLastError(NO_ERROR); |
|||
- const DWORD position = SetFilePointer(d->file, 0, NULL, FILE_CURRENT);
|
|||
+ LARGE_INTEGER lOffset;
|
|||
+ lOffset.QuadPart = 0;
|
|||
+ const DWORD position = SetFilePointerEx(d->file, lOffset, NULL, FILE_CURRENT);
|
|||
if(GetLastError() == NO_ERROR) { |
|||
return static_cast<long>(position); |
|||
} |
|||
--
|
|||
2.26.0.windows.1 |
|||
|
|||
@ -1,39 +0,0 @@ |
|||
From 9c02a2c245bed1d70dbd80b0e63abbcdecb74761 Mon Sep 17 00:00:00 2001 |
|||
From: Steve Lhomme <robux4@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 |
|||
|
|||
@ -1,43 +0,0 @@ |
|||
From a9024bd18ce20653616e04702b5e220de56b6b2c Mon Sep 17 00:00:00 2001 |
|||
From: Steve Lhomme <robux4@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 |
|||
|
|||
@ -1 +1 @@ |
|||
7846775c4954ea948fe4383e514ba7c11f55d038ee06b6ea5a0a1c1069044b348026e76b27aa4ba1c71539aa8143e1401fab39184cc6e915ba0ae2c06133cb98 taglib-1.11.1.tar.gz |
|||
7e369faa5e3c6c6401052b7a19e35b0cf8c1e5ed9597053ac731a7718791d5d4803d1b18a93e903ec8c3fc6cb92e34d9616daa2ae4d326965d4c4d5624dcdaba taglib-1.12.tar.gz |
|||
|
|||
@ -1,44 +0,0 @@ |
|||
From e648e07b7ebc4a1254a8673388c8f578fedf62a6 Mon Sep 17 00:00:00 2001 |
|||
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr> |
|||
Date: Mon, 18 Mar 2019 15:57:28 +0100 |
|||
Subject: [PATCH] fileref: Use user defined resolvers with IOStream |
|||
|
|||
---
|
|||
taglib/fileref.cpp | 14 +++++++------- |
|||
1 file changed, 7 insertions(+), 7 deletions(-) |
|||
|
|||
diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp
|
|||
index 3a7f2c65..b0369a0c 100644
|
|||
--- a/taglib/fileref.cpp
|
|||
+++ b/taglib/fileref.cpp
|
|||
@@ -88,13 +88,6 @@ namespace
|
|||
return 0; |
|||
} |
|||
|
|||
- template <>
|
|||
- File *resolveFileType<IOStream *>(IOStream *arg, bool readProperties,
|
|||
- AudioProperties::ReadStyle style)
|
|||
- {
|
|||
- return 0;
|
|||
- }
|
|||
-
|
|||
template <> |
|||
File *resolveFileType<FileName>(FileName arg, bool readProperties, |
|||
AudioProperties::ReadStyle style) |
|||
@@ -109,6 +102,13 @@ namespace
|
|||
return 0; |
|||
} |
|||
|
|||
+ template <>
|
|||
+ File *resolveFileType<IOStream *>(IOStream *arg, bool readProperties,
|
|||
+ AudioProperties::ReadStyle style)
|
|||
+ {
|
|||
+ return resolveFileType(arg->name(), readProperties, style);
|
|||
+ }
|
|||
+
|
|||
template <typename T> |
|||
File* createInternal(T arg, bool readAudioProperties, |
|||
AudioProperties::ReadStyle audioPropertiesStyle) |
|||
--
|
|||
2.20.1 |
|||
|
|||
Loading…
Reference in new issue