lib/nfs/FileReader: use `struct stat64` on Windows 32-bit

libnfs is compiled with `-D_FILE_OFFSET_BITS=64`, but Meson decides
not to enable this mode.  We could force this mode, but then again,
these days, nobody should be using 32-bit Windows ... so this is a
kludge only for debugging with 32-bit WINE.
This commit is contained in:
Max Kellermann 2020-04-23 17:30:58 +02:00
parent fdb28eb0c4
commit 3040ddb5ec
1 changed files with 11 additions and 2 deletions

View File

@ -196,11 +196,20 @@ NfsFileReader::OpenCallback(nfsfh *_fh) noexcept
}
inline void
NfsFileReader::StatCallback(const struct stat *st) noexcept
NfsFileReader::StatCallback(const struct stat *_st) noexcept
{
assert(connection != nullptr);
assert(fh != nullptr);
assert(st != nullptr);
assert(_st != nullptr);
#if defined(_WIN32) && !defined(_WIN64)
/* on 32-bit Windows, libnfs enables -D_FILE_OFFSET_BITS=64,
but MPD (Meson) doesn't - to work around this mismatch, we
cast explicitly to "struct stat64" */
const auto *st = (const struct stat64 *)_st;
#else
const auto *st = _st;
#endif
if (!S_ISREG(st->st_mode)) {
OnNfsFileError(std::make_exception_ptr(std::runtime_error("Not a regular file")));