Skip to content

Commit 07a8210

Browse files
committed
Support new mingw stat/stat64 behaviour.
Changes were introduced in the following commit: https://sourceforge.net/p/mingw-w64/mingw-w64/ci/07e34538d5a7d5e86ab47c7ba47becb32f7d827e/
1 parent 30e0356 commit 07a8210

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/common/file-utils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ int rnp_open(const char *filename, int oflag, int pmode);
3939
FILE * rnp_fopen(const char *filename, const char *mode);
4040
FILE * rnp_fdopen(int fildes, const char *mode);
4141
int rnp_access(const char *path, int mode);
42-
#ifdef _WIN32 /* Default to __stat64 structure */
42+
#if defined(_WIN32) && !defined(HAVE_WIN_STAT)
43+
/* Default to __stat64 structure unless defined by mingw since commit [07e345] */
4344
#define stat __stat64
4445
#endif
4546
int rnp_stat(const char *filename, struct stat *statbuf);

src/lib/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ check_cxx_symbol_exists(_O_BINARY fcntl.h HAVE__O_BINARY)
9595
check_cxx_symbol_exists(_tempnam stdio.h HAVE__TEMPNAM)
9696
set(HAVE_ZLIB_H "${ZLIB_FOUND}")
9797
set(HAVE_BZLIB_H "${BZIP2_FOUND}")
98+
if (WIN32)
99+
include(CheckCSourceCompiles)
100+
101+
check_c_source_compiles("
102+
#include <sys/types.h>
103+
#include <sys/stat.h>
104+
#include <unistd.h>
105+
int main() { struct stat s; return 0; }" HAVE_WIN_STAT)
106+
endif()
98107

99108
# Checks feature in CRYPTO_BACKEND and puts the result into variable whose name is stored in RESULT_VARNAME variable.
100109
function(backend_has_feature FEATURE RESULT_VARNAME)

src/lib/config.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#cmakedefine HAVE_O_BINARY
5050
#cmakedefine HAVE__O_BINARY
5151
#cmakedefine HAVE__TEMPNAM
52+
#cmakedefine HAVE_WIN_STAT
5253

5354
#cmakedefine CRYPTO_BACKEND_BOTAN
5455
#cmakedefine CRYPTO_BACKEND_BOTAN3

0 commit comments

Comments
 (0)