Jelajahi Sumber

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.
doctor-claw 3 hari lalu
induk
melakukan
a4697bd29d
1 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 2 2
      httplib.h

+ 2 - 2
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