MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / SetLastFilePosition

Method SetLastFilePosition

lib/mdflib/mdflib/src/mdfblock.cpp:690–704  ·  view source on GitHub ↗

size_t MdfBlock::Write(std::FILE *file) { if (file == nullptr) { throw std::runtime_error("File pointer is null"); } SetLastFilePosition(file); file_position_ = GetFilePosition(file); size_t bytes = 0; if (IsMdf4()) { bytes += WriteStr(file, block_type_, 4); const std::vector reserved(4, 0); bytes += WriteByte(file, reserved); bytes += WriteNumber(file, bl

Source from the content-addressed store, hash-verified

688}
689*/
690void MdfBlock::SetLastFilePosition(std::streambuf& buffer) const {
691 constexpr char fill = 0;
692 auto pos = buffer.pubseekoff(0, std::ios_base::end);
693 if (pos < 0) {
694 throw std::ios_base::failure("Failed to set last file position");
695 }
696 if (IsMdf4()) {
697 // If this is an MDF4 file, fill with empty byte so the position
698 // has 64-bits alignments.
699 for (pos = GetFilePosition(buffer); (pos % 8) != 0;
700 pos = GetFilePosition(buffer)) {
701 buffer.sputc(fill);
702 }
703 }
704}
705/*
706void MdfBlock::SetLastFilePosition(std::FILE *file) const {
707 Platform::fseek64(file, 0, SEEK_END);

Callers 2

SetLastPositionMethod · 0.80
SetLastPositionMethod · 0.80

Calls 2

failureFunction · 0.85
GetFilePositionFunction · 0.85

Tested by

no test coverage detected