From 152cabab7c8b2c81e89b4616a092b0c25c0b1ced Mon Sep 17 00:00:00 2001 From: Edwin Wu Date: Wed, 5 Jun 2024 05:41:33 -0700 Subject: [PATCH] Fix a bug in file payload. PiperOrigin-RevId: 640494382 --- connections/payload_type.h | 2 +- internal/platform/implementation/shared/file.cc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/connections/payload_type.h b/connections/payload_type.h index fd09a104..eeca1ebd 100644 --- a/connections/payload_type.h +++ b/connections/payload_type.h @@ -19,7 +19,7 @@ namespace nearby { namespace connections { enum class PayloadType { kUnknown = 0, kBytes = 1, kFile = 2, kStream = 3 }; -enum PayloadDirection { +enum class PayloadDirection { UNKNOWN_DIRECTION_PAYLOAD = 0, INCOMING_PAYLOAD = 1, OUTGOING_PAYLOAD = 2, diff --git a/internal/platform/implementation/shared/file.cc b/internal/platform/implementation/shared/file.cc index 97ffe947..a78ca9f2 100644 --- a/internal/platform/implementation/shared/file.cc +++ b/internal/platform/implementation/shared/file.cc @@ -14,7 +14,6 @@ #include "internal/platform/implementation/shared/file.h" -#include #include #include #include @@ -37,7 +36,7 @@ IOFile::IOFile(const absl::string_view file_path, size_t size) : file_(std::string(file_path.data(), file_path.size()), std::ios::binary | std::ios::in | std::ios::ate), path_(file_path), - total_size_(file_.tellg()) { + total_size_(size) { file_.seekg(0); }