Second attempt at fixing CfAPI wrapper build in Win32 mode

MSVC having so useless error messages it didn't quite point to the root
cause of the issue... it turns out that through the maze of macros
defined in the windows API, there's one which impacted the function
pointer definition of CfCloseHandle which would then not convert to
FileHandle::Deleter as expected. So I end up wrapping it in a lambda to
help... luckily this kind of lambdas decay into a simple function
pointer so there's likely no overhead it's just to coerce the compiler
into doing the right thing.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2021-01-07 13:41:51 +01:00
parent 79a54d68ed
commit 2d8eb19ee5
No known key found for this signature in database
GPG Key ID: 074BBBCB8DECC9E2
1 changed files with 1 additions and 1 deletions

View File

@ -346,7 +346,7 @@ OCC::CfApiWrapper::FileHandle OCC::CfApiWrapper::handleForPath(const QString &pa
HANDLE handle = nullptr;
const qint64 openResult = CfOpenFileWithOplock(path.toStdWString().data(), CF_OPEN_FILE_FLAG_NONE, &handle);
if (openResult == S_OK) {
return {handle, CfCloseHandle};
return {handle, [](HANDLE h) { CfCloseHandle(h); }};
}
} else {
const auto handle = CreateFile(path.toStdWString().data(), 0, 0, nullptr,