diff --git a/internal/platform/implementation/windows/file.cc b/internal/platform/implementation/windows/file.cc index 0ce81ed7..4102602d 100644 --- a/internal/platform/implementation/windows/file.cc +++ b/internal/platform/implementation/windows/file.cc @@ -42,6 +42,13 @@ IOFile::IOFile(const absl::string_view file_path, size_t size) file_.open(wide_path, std::ios::binary | std::ios::in | std::ios::ate); total_size_ = file_.tellg(); + if (total_size_ == -1) { + // Unsure why it consistently returns -1 when the file size exceeds 2GB. If + // obtaining the file size through tellg fails, use the size provided + // in the parameters. + total_size_ = size; + } + file_.seekg(0); }