static
| 32 | |
| 33 | // static |
| 34 | SHA1::Hash SHA1::Calculate(std::string const & filePath) |
| 35 | { |
| 36 | try |
| 37 | { |
| 38 | base::FileData file(filePath, base::FileData::Op::READ); |
| 39 | uint64_t const fileSize = file.Size(); |
| 40 | |
| 41 | boost::uuids::detail::sha1 sha1; |
| 42 | |
| 43 | uint64_t currSize = 0; |
| 44 | uint32_t constexpr kFileBufferSize = 8192; |
| 45 | unsigned char buffer[kFileBufferSize]; |
| 46 | while (currSize < fileSize) |
| 47 | { |
| 48 | auto const toRead = std::min(kFileBufferSize, static_cast<uint32_t>(fileSize - currSize)); |
| 49 | file.Read(currSize, buffer, toRead); |
| 50 | sha1.process_bytes(buffer, toRead); |
| 51 | currSize += toRead; |
| 52 | } |
| 53 | return ExtractHash(sha1); |
| 54 | } |
| 55 | catch (Reader::Exception const & ex) |
| 56 | { |
| 57 | LOG(LERROR, ("Error reading file:", filePath, ex.what())); |
| 58 | } |
| 59 | return {}; |
| 60 | } |
| 61 | |
| 62 | // static |
| 63 | std::string SHA1::CalculateBase64(std::string const & filePath) |
nothing calls this directly
no test coverage detected