From a4697bd29d1bcc329573e7e7ce8cf96b908f94e9 Mon Sep 17 00:00:00 2001 From: doctor-claw <54720201+doctor-claw@users.noreply.github.com> Date: Wed, 2 Dec 2026 05:21:45 +0000 Subject: [PATCH] Use 64-bit stat in FileStat on Windows (#2705) FileStat used struct _stat and _wstat on Windows, whose st_size is 32-bit, so _wstat failed with EOVERFLOW for a file of 2 GiB or more. is_file() then returned false, and set_mount_point served 404 for a file that exists; size() and mtime() had the same limit. struct _stat64 and _wstat64 have a 64-bit st_size. --- httplib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httplib.h b/httplib.h index 32ad9c6e..984069f1 100644 --- a/httplib.h +++ b/httplib.h @@ -3898,7 +3898,7 @@ struct FileStat { private: #if defined(_WIN32) - struct _stat st_; + struct _stat64 st_; #else struct stat st_; #endif @@ -6464,7 +6464,7 @@ inline bool is_path_within_base(const std::string &resolved_path, inline FileStat::FileStat(const std::string &path) { #if defined(_WIN32) auto wpath = u8string_to_wstring(path.c_str()); - ret_ = _wstat(wpath.c_str(), &st_); + ret_ = _wstat64(wpath.c_str(), &st_); #else ret_ = stat(path.c_str(), &st_); #endif