From 3b602a2984bbe23fc5642ce109200bd54037a66b Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Thu, 22 Jun 2023 12:16:18 +0200 Subject: [PATCH] More Windows fixes --- include/dwarfs/file_stat.h | 8 +++++--- src/dwarfs/filesystem_extractor.cpp | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/dwarfs/file_stat.h b/include/dwarfs/file_stat.h index 427aa88e..1553d536 100644 --- a/include/dwarfs/file_stat.h +++ b/include/dwarfs/file_stat.h @@ -81,7 +81,7 @@ struct file_stat { time_type ctime; }; -template +template void copy_file_stat(T* out, file_stat const& in) { out->st_dev = in.dev; out->st_ino = in.ino; @@ -91,8 +91,10 @@ void copy_file_stat(T* out, file_stat const& in) { out->st_gid = in.gid; out->st_rdev = in.rdev; out->st_size = in.size; - out->st_blksize = in.blksize; - out->st_blocks = in.blocks; + if constexpr (with_block_info) { + out->st_blksize = in.blksize; + out->st_blocks = in.blocks; + } out->st_atime = in.atime; out->st_mtime = in.mtime; out->st_ctime = in.ctime; diff --git a/src/dwarfs/filesystem_extractor.cpp b/src/dwarfs/filesystem_extractor.cpp index 6e661640..2e2690ad 100644 --- a/src/dwarfs/filesystem_extractor.cpp +++ b/src/dwarfs/filesystem_extractor.cpp @@ -336,7 +336,11 @@ bool filesystem_extractor_::extract( struct stat st; ::memset(&st, 0, sizeof(st)); - copy_file_stat(&st, stbuf); +#ifdef _WIN32 + copy_file_stat(&st, stbuf); +#else + copy_file_stat(&st, stbuf); +#endif ::archive_entry_set_pathname(ae, entry.path().c_str()); ::archive_entry_copy_stat(ae, &st);