MCPcopy Create free account
hub / github.com/Kitware/CMake / ByteHashStream

Method ByteHashStream

Source/cmCryptoHash.cxx:156–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156std::vector<unsigned char> cmCryptoHash::ByteHashStream(std::istream& sin)
157{
158 if (sin) {
159 this->Initialize();
160 {
161 // Should be efficient enough on most system:
162 KWIML_INT_uint64_t buffer[512];
163 char* buffer_c = reinterpret_cast<char*>(buffer);
164 unsigned char const* buffer_uc =
165 reinterpret_cast<unsigned char const*>(buffer);
166 // This copy loop is very sensitive on certain platforms with
167 // slightly broken stream libraries (like HPUX). Normally, it is
168 // incorrect to not check the error condition on the fin.read()
169 // before using the data, but the fin.gcount() will be zero if an
170 // error occurred. Therefore, the loop should be safe everywhere.
171 while (sin) {
172 sin.read(buffer_c, sizeof(buffer));
173 if (int gcount = static_cast<int>(sin.gcount())) {
174 this->Append(buffer_uc, gcount);
175 }
176 }
177 }
178 if (sin.eof()) {
179 // Success
180 return this->Finalize();
181 }
182 // Finalize anyway
183 this->Finalize();
184 }
185 // Return without success
186 return std::vector<unsigned char>();
187}
188
189std::vector<unsigned char> cmCryptoHash::ByteHashFile(std::string const& file)
190{

Callers 2

ByteHashFileMethod · 0.95
HashStreamMethod · 0.95

Calls 4

InitializeMethod · 0.95
AppendMethod · 0.95
FinalizeMethod · 0.95
readMethod · 0.45

Tested by

no test coverage detected