summaryrefslogtreecommitdiff
path: root/libraries/ESP_Async_WebServer/src/ChunkPrint.cpp
blob: 4617d34a0acbd14041be52a8a5547999dbf35fdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2025 Hristo Gochkov, Mathieu Carbou, Emil Muratov

#include <ChunkPrint.h>

ChunkPrint::ChunkPrint(uint8_t *destination, size_t from, size_t len) : _destination(destination), _to_skip(from), _to_write(len), _pos{0} {}

size_t ChunkPrint::write(uint8_t c) {
  if (_to_skip > 0) {
    _to_skip--;
    return 1;
  } else if (_to_write > 0) {
    _to_write--;
    _destination[_pos++] = c;
    return 1;
  }
  return 0;
}