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

polserver / polserver / 21047054485

15 Jan 2026 09:31PM UTC coverage: 60.507% (-0.001%) from 60.508%
21047054485

push

github

web-flow
Clang Tidy default constructor  (#852)

* trigger clang tidy

* Automated clang-tidy change: modernize-use-equals-default

* compile test

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>

58 of 75 new or added lines in 41 files covered. (77.33%)

1 existing line in 1 file now uncovered.

44460 of 73479 relevant lines covered (60.51%)

507363.1 hits per line

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

60.0
/pol-core/clib/binaryfile.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2009/08/25 Shinigami: STLport-5.2.1 fix: Error message in BinaryFile::Seek stripped little bit.
5
 * - 2009/09/01 MuadDib:   STLPort-5.x fix: BinaryFile::Seek requires casting to long in decint
6
 * under Win32
7
 */
8

9

10
#include "binaryfile.h"
11

12
#include <stdexcept>
13

14
#include "passert.h"
15
#include "strutil.h"
16

17
namespace Pol
18
{
19
namespace Clib
20
{
NEW
21
BinaryFile::BinaryFile() = default;
×
22

23
BinaryFile::BinaryFile( const std::string& filename, std::ios::openmode mode ) : _filename( "" )
42✔
24
{
25
  Open( filename, mode );
42✔
26
}
42✔
27

28
BinaryFile::~BinaryFile() = default;
42✔
29

30
void BinaryFile::Open( const std::string& filename, std::ios::openmode mode )
42✔
31
{
32
  passert( !_file.is_open() );
42✔
33

34
  _filename = filename;
42✔
35

36
  _file.open( _filename.c_str(), mode | std::ios::binary );
42✔
37
  if ( !_file.is_open() )
42✔
38
    throw std::runtime_error( "BinaryFile::Open('" + _filename + ", " + hexint( mode ) +
×
39
                              ") failed." );
×
40
}
42✔
41

42
void BinaryFile::Close()
×
43
{
44
  passert( _file.is_open() );
×
45

46
  _file.close();
×
47
  _filename = "";
×
48
}
×
49

50
void BinaryFile::Seek( std::fstream::pos_type abs_offset )
8✔
51
{
52
  passert( _file.is_open() );
8✔
53

54
  if ( !_file.seekg( abs_offset, std::ios::beg ) )
8✔
55
    throw std::runtime_error( "BinaryFile::Seek('" + _filename + "') failed." );
×
56
}
8✔
57

58
void BinaryFile::ReadBuffer( void* buffer, std::streamsize length )
121,766✔
59
{
60
  if ( !_file.read( reinterpret_cast<char*>( buffer ), length ) )
121,766✔
61
    throw std::runtime_error( "BinaryFile::Read('" + _filename + "') failed to read " +
×
62
                              tostring( static_cast<int>( length ) ) + " bytes." );
×
63
}
121,766✔
64

65
std::fstream::pos_type BinaryFile::FileSize()
24✔
66
{
67
  passert( _file.is_open() );
24✔
68

69
  std::fstream::pos_type save_pos = _file.tellg();
24✔
70
  if ( save_pos == std::fstream::pos_type( -1 ) )
24✔
71
    throw std::runtime_error( "BinaryFile::FileSize('" + _filename +
×
72
                              "' failed to determine current position." );
×
73

74
  if ( !_file.seekg( 0, std::ios::end ) )
24✔
75
    throw std::runtime_error( "BinaryFile::FileSize('" + _filename +
×
76
                              "') failed to seek to end of file." );
×
77
  std::fstream::pos_type size = _file.tellg();
24✔
78
  if ( size == std::fstream::pos_type( -1 ) )
24✔
79
    throw std::runtime_error( "BinaryFile::FileSize('" + _filename +
×
80
                              "') could not determine file size." );
×
81

82
  if ( !_file.seekg( save_pos ) )
24✔
83
    throw std::runtime_error( "BinaryFile::FileSize('" + _filename +
×
84
                              "') failed to seek to original position." );
×
85

86
  return size;
24✔
87
}
88

89
size_t BinaryFile::GetElementCount( size_t elemsize )
18✔
90
{
91
  std::fstream::pos_type filesize = FileSize();
18✔
92
  if ( ( filesize % elemsize ) != 0 )
18✔
93
  {
94
    throw std::runtime_error( _filename +
×
95
                              " does not contain an integral number of elements of size " +
×
96
                              tostring( elemsize ) );
×
97
  }
98
  return static_cast<unsigned int>( filesize / elemsize );
18✔
99
}
100

101
size_t BinaryFile::sizeEstimate() const
2✔
102
{
103
  size_t size = sizeof( *this ) + _filename.capacity();
2✔
104
  return size;
2✔
105
}
106
}  // namespace Clib
107
}  // namespace Pol
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