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

Method CopyDataToFile

lib/mdflib/mdflib/src/dz4block.cpp:80–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80uint64_t Dz4Block::CopyDataToFile(std::streambuf& from_file,
81 std::streambuf& to_file) const {
82 if (data_position_ == 0 || orig_data_length_ == 0 || data_length_ == 0) {
83 return 0;
84 }
85 SetFilePosition(from_file, data_position_);
86
87 uint64_t count = 0;
88 switch (static_cast<Dz4ZipType>(type_)) {
89 case Dz4ZipType::Deflate: {
90 const bool inflate = Inflate(from_file, to_file, data_length_);
91 count = inflate ? orig_data_length_ : 0;
92 break;
93 }
94
95 case Dz4ZipType::TransposeAndDeflate: {
96 ByteArray temp(static_cast<size_t>(data_length_), 0);
97 from_file.sgetn(
98 reinterpret_cast<char*>(temp.data()),
99 static_cast<std::streamsize>(temp.size()) );
100 ByteArray out(static_cast<size_t>(orig_data_length_), 0);
101 const bool inflate = Inflate(temp, out);
102 InvTranspose(out, parameter_);
103 to_file.sputn(reinterpret_cast<char*>(out.data()),
104 static_cast<std::streamsize>(out.size()) );
105 count = inflate ? orig_data_length_ : 0;
106 break;
107 }
108
109 default:
110 break;
111 }
112 return count;
113}
114
115uint64_t Dz4Block::CopyDataToBuffer(std::streambuf& from_file,
116 std::vector<uint8_t> &dest,

Callers 1

CopyDataToFileFunction · 0.45

Calls 5

SetFilePositionFunction · 0.85
InflateFunction · 0.85
InvTransposeFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected