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

randombit / botan / 5123321399

30 May 2023 04:06PM UTC coverage: 92.213% (+0.004%) from 92.209%
5123321399

Pull #3558

github

web-flow
Merge dd72f7389 into 057bcbc35
Pull Request #3558: Add braces around all if/else statements

75602 of 81986 relevant lines covered (92.21%)

11859779.3 hits per line

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

46.67
/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/internal/fmt.h>
14
#include <ostream>
15

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

20
namespace Botan {
21

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

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

37
/*
38
* DataSink_Stream Constructor
39
*/
40
DataSink_Stream::DataSink_Stream(std::ostream& out, std::string_view name) : m_identifier(name), m_sink(out) {}
4✔
41

42
#if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
43

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

57
DataSink_Stream::~DataSink_Stream() = default;
4✔
58

59
}  // 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