Skip to content

Commit 2d12c93

Browse files
ktakahashimtbdillof
authored andcommitted
Fix Windows 64 bit API
1 parent 9203514 commit 2d12c93

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ check_function_exists(_fdopen HAVE__FDOPEN)
105105
check_function_exists(_fileno HAVE__FILENO)
106106
check_function_exists(_fseeki64 HAVE__FSEEKI64)
107107
check_function_exists(_fstat64 HAVE__FSTAT64)
108+
check_function_exists(_ftelli64 HAVE__FTELLI64)
108109
check_function_exists(_setmode HAVE__SETMODE)
109110
check_function_exists(_stat64 HAVE__STAT64)
110111
check_symbol_exists(_snprintf stdio.h HAVE__SNPRINTF)

config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#cmakedefine HAVE__FILENO
1313
#cmakedefine HAVE__FSEEKI64
1414
#cmakedefine HAVE__FSTAT64
15+
#cmakedefine HAVE__FTELLI64
1516
#cmakedefine HAVE__SETMODE
1617
#cmakedefine HAVE__SNPRINTF
1718
#cmakedefine HAVE__SNPRINTF_S

lib/compat.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
#include "config.h"
4040

41+
#include <sys/stat.h>
42+
4143
/* to have *_MAX definitions for all types when compiling with g++ */
4244
#define __STDC_LIMIT_MACROS
4345

@@ -124,19 +126,19 @@ typedef char bool;
124126
#endif
125127

126128

127-
#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__SEEK64)
129+
#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__FTELLI64)
128130
/* Windows API using int64 */
129131
typedef zip_int64_t zip_off_t;
130132
typedef struct _stat64 zip_os_stat_t;
131133
#define zip_os_stat _stat64
132134
#define zip_os_fstat _fstat64
133-
#define zip_os_seek _fseeki64
135+
#define zip_os_fseek _fseeki64
136+
#define zip_os_ftell _ftelli64
134137
#define ZIP_FSEEK_MAX ZIP_INT64_MAX
135138
#define ZIP_FSEEK_MIN ZIP_INT64_MIN
136139
#else
137140

138141
/* Normal API */
139-
#include <sys/stat.h>
140142
typedef struct stat zip_os_stat_t;
141143
#define zip_os_fstat fstat
142144
#define zip_os_stat stat
@@ -222,10 +224,10 @@ typedef long zip_off_t;
222224

223225
#ifndef HAVE_STRERROR_S
224226
#define strerrorlen_s(errnum) (strlen(strerror(errnum)))
225-
#define strerror_s(buf, bufsz, errnum) ((void)strncpy_s((buf), (bufsz), strerror(errnum), (bufsz)), (buf)[(bufsz)-1] = '\0', strerrorlen_s(errnum) >= (bufsz))
227+
#define strerror_s(buf, bufsz, errnum) ((void)strncpy_s((buf), (bufsz), strerror(errnum), (bufsz)), (buf)[(bufsz) - 1] = '\0', strerrorlen_s(errnum) >= (bufsz))
226228
#else
227229
#ifndef HAVE_STRERRORLEN_S
228-
#define strerrorlen_s(errnum) 8192
230+
#define strerrorlen_s(errnum) 8192
229231
#endif
230232
#endif
231233

@@ -259,11 +261,11 @@ typedef long zip_off_t;
259261
#endif
260262

261263
#ifndef S_ISDIR
262-
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
264+
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
263265
#endif
264266

265267
#ifndef S_ISREG
266-
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
268+
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
267269
#endif
268270

269271
#endif /* compat.h */

0 commit comments

Comments
 (0)