Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ check_function_exists(_fdopen HAVE__FDOPEN)
check_function_exists(_fileno HAVE__FILENO)
check_function_exists(_fseeki64 HAVE__FSEEKI64)
check_function_exists(_fstat64 HAVE__FSTAT64)
check_function_exists(_ftelli64 HAVE__FTELLI64)
check_function_exists(_setmode HAVE__SETMODE)
check_function_exists(_stat64 HAVE__STAT64)
check_symbol_exists(_snprintf stdio.h HAVE__SNPRINTF)
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#cmakedefine HAVE__FILENO
#cmakedefine HAVE__FSEEKI64
#cmakedefine HAVE__FSTAT64
#cmakedefine HAVE__FTELLI64
#cmakedefine HAVE__SETMODE
#cmakedefine HAVE__SNPRINTF
#cmakedefine HAVE__SNPRINTF_S
Expand Down
16 changes: 9 additions & 7 deletions lib/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

#include "config.h"

#include <sys/stat.h>

/* to have *_MAX definitions for all types when compiling with g++ */
#define __STDC_LIMIT_MACROS

Expand Down Expand Up @@ -124,19 +126,19 @@ typedef char bool;
#endif


#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__SEEK64)
#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__FTELLI64)
/* Windows API using int64 */
typedef zip_int64_t zip_off_t;
typedef struct _stat64 zip_os_stat_t;
#define zip_os_stat _stat64
#define zip_os_fstat _fstat64
#define zip_os_seek _fseeki64
#define zip_os_fseek _fseeki64
#define zip_os_ftell _ftelli64
#define ZIP_FSEEK_MAX ZIP_INT64_MAX
#define ZIP_FSEEK_MIN ZIP_INT64_MIN
#else

/* Normal API */
#include <sys/stat.h>
typedef struct stat zip_os_stat_t;
#define zip_os_fstat fstat
#define zip_os_stat stat
Expand Down Expand Up @@ -222,10 +224,10 @@ typedef long zip_off_t;

#ifndef HAVE_STRERROR_S
#define strerrorlen_s(errnum) (strlen(strerror(errnum)))
#define strerror_s(buf, bufsz, errnum) ((void)strncpy_s((buf), (bufsz), strerror(errnum), (bufsz)), (buf)[(bufsz)-1] = '\0', strerrorlen_s(errnum) >= (bufsz))
#define strerror_s(buf, bufsz, errnum) ((void)strncpy_s((buf), (bufsz), strerror(errnum), (bufsz)), (buf)[(bufsz) - 1] = '\0', strerrorlen_s(errnum) >= (bufsz))
#else
#ifndef HAVE_STRERRORLEN_S
#define strerrorlen_s(errnum) 8192
#define strerrorlen_s(errnum) 8192
#endif
#endif

Expand Down Expand Up @@ -259,11 +261,11 @@ typedef long zip_off_t;
#endif

#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif

#ifndef S_ISREG
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif

#endif /* compat.h */