• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 6704830136

31 Oct 2023 09:55AM UTC coverage: 91.722% (+0.001%) from 91.721%
6704830136

push

github

web-flow
Merge pull request #3752 from randombit/jack/allocator-helper

Split out allocator helpers to allocator.h

80150 of 87384 relevant lines covered (91.72%)

8593301.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.94
/src/lib/filters/data_snk.cpp
1
/*
2
* DataSink
3
* (C) 1999-2007 Jack Lloyd
4
*     2005 Matthew Gregan
5
*     2017 Philippe Lieser
6
*
7
* Botan is released under the Simplified BSD License (see license.txt)
8
*/
9

10
#include <botan/data_snk.h>
11

12
#include <botan/exceptn.h>
13
#include <botan/mem_ops.h>
14
#include <botan/internal/fmt.h>
15
#include <ostream>
16

17
#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
18
   #include <fstream>
19
#endif
20

21
namespace Botan {
22

23
/*
24
* Write to a stream
25
*/
26
void DataSink_Stream::write(const uint8_t out[], size_t length) {
4✔
27
   m_sink.write(cast_uint8_ptr_to_char(out), length);
4✔
28
   if(!m_sink.good()) {
4✔
29
      throw Stream_IO_Error("DataSink_Stream: Failure writing to " + m_identifier);
×
30
   }
31
}
4✔
32

33
/*
34
* Flush the stream
35
*/
36
void DataSink_Stream::end_msg() {
4✔
37
   m_sink.flush();
4✔
38
}
4✔
39

40
/*
41
* DataSink_Stream Constructor
42
*/
43
DataSink_Stream::DataSink_Stream(std::ostream& out, std::string_view name) : m_identifier(name), m_sink(out) {}
4✔
44

45
#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
46

47
/*
48
* DataSink_Stream Constructor
49
*/
50
DataSink_Stream::DataSink_Stream(std::string_view path, bool use_binary) :
×
51
      m_identifier(path),
×
52
      m_sink_memory(std::make_unique<std::ofstream>(std::string(path), use_binary ? std::ios::binary : std::ios::out)),
×
53
      m_sink(*m_sink_memory) {
×
54
   if(!m_sink.good()) {
×
55
      throw Stream_IO_Error(fmt("DataSink_Stream: Failure opening path '{}'", path));
×
56
   }
57
}
×
58
#endif
59

60
DataSink_Stream::~DataSink_Stream() = default;
4✔
61

62
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc