Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file size limitation with zip_source_filep_create on Windows. #452

Closed
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
19 changes: 15 additions & 4 deletions lib/zip_source_file_stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@
#include <sys/stat.h>

#ifdef _WIN32
#define STAT_ST _stat64
#define STAT_F _stat64
#define FSTAT_F _fstat64
#define FSEEK_F _fseeki64
#define OFF_T __int64
#ifndef S_IWUSR
#define S_IWUSR _S_IWRITE
#endif
#else
#define STAT_ST stat
#define STAT_F stat
#define FSTAT_F fstat
#define FSEEK_F fseeko
#define OFF_T off_t
#endif

/* clang-format off */
Expand Down Expand Up @@ -120,7 +131,7 @@ _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,
}
#endif

if (fseeko((FILE *)f, (off_t)offset, whence) < 0) {
if (FSEEK_F((FILE *)f, (OFF_T)offset, whence) < 0) {
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
return false;
}
Expand All @@ -130,15 +141,15 @@ _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,

bool
_zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
struct stat sb;
struct STAT_ST sb;

int ret;

if (ctx->fname) {
ret = stat(ctx->fname, &sb);
ret = STAT_F(ctx->fname, &sb);
}
else {
ret = fstat(fileno((FILE *)ctx->f), &sb);
ret = FSTAT_F(fileno((FILE *)ctx->f), &sb);
}

if (ret < 0) {
Expand Down