LCOV - code coverage report
Current view: top level - libs/http_proto/src/file_source.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 95.2 % 21 20
Test Date: 2025-09-21 18:08:14 Functions: 75.0 % 4 3

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com)
       3              : // Copyright (c) 2025 Mohammad Nejati
       4              : //
       5              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       6              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       7              : //
       8              : // Official repository: https://github.com/cppalliance/http_proto
       9              : //
      10              : 
      11              : #include <boost/http_proto/file_source.hpp>
      12              : 
      13              : namespace boost {
      14              : namespace http_proto {
      15              : 
      16            3 : file_source::
      17              : ~file_source() = default;
      18              : 
      19            0 : file_source::
      20              : file_source(file_source&&) noexcept = default;
      21              : 
      22            3 : file_source::
      23              : file_source(
      24              :     file&& f,
      25            3 :     std::uint64_t limit) noexcept
      26            3 :     : f_(std::move(f))
      27            3 :     , n_(limit)
      28              : {
      29            3 : }
      30              : 
      31              : auto
      32            7 : file_source::
      33              : on_read(
      34              :     buffers::mutable_buffer b) -> results
      35              : {
      36            7 :     results rv;
      37            7 :     if(n_ > 0)
      38              :     {
      39              :         std::size_t n;
      40            7 :         if( n_ >= b.size())
      41            6 :             n = b.size();
      42              :         else
      43            1 :             n = static_cast<std::size_t>(n_);
      44            7 :         n = f_.read(
      45              :             b.data(), n, rv.ec);
      46            7 :         rv.bytes = n;
      47            7 :         if(n == 0 && b.size() != 0 && !rv.ec)
      48              :         {
      49            1 :             rv.finished = true;
      50            1 :             return rv;
      51              :         }
      52            6 :         n_ -= n;
      53              :     }
      54            6 :     rv.finished = n_ == 0;
      55            6 :     return rv;
      56              : }
      57              : 
      58              : } // http_proto
      59              : } // boost
        

Generated by: LCOV version 2.1