53 for (i = 0; i < blocks; i++) {
54 stat = f.
read(block_data, bytes_to_read);
60 hash.
update(block_data, bytes_to_read);
64 bytes_to_read = remaining_bytes;
65 if (remaining_bytes > 0) {
66 stat = f.
read(block_data, bytes_to_read);
72 hash.
update(block_data, remaining_bytes);
95 U8 checksum_data[
sizeof(checksum)] = {};
100 bytes_to_write = checksum_buffer.
getSize();
130 U8 checksum_data[
sizeof(checksum_from_file)] = {};
132 stat = f.
read(checksum_data, checksum_from_file_size);
133 if (stat !=
Os::File::OP_OK || checksum_from_file_size !=
sizeof(checksum_from_file)) {
140 checksum_buffer.
fill();
161 U32 checksum_from_file;
179 for (i = 0; i < blocks; i++) {
180 stat = f.
read(block_data, bytes_to_read);
186 hash.
update(block_data, static_cast<FwSizeType>(bytes_to_read));
190 bytes_to_read = remaining_bytes;
191 if (remaining_bytes > 0) {
192 stat = f.
read(block_data, bytes_to_read);
198 hash.
update(block_data, remaining_bytes);
212 if (checksum != checksum_from_file) {
213 expected = checksum_from_file;
218 expected = checksum_from_file;
#define HASH_EXTENSION_STRING
void update(const void *const data, const FwSizeType len)
Serialization/Deserialization operation was successful.
A variable-length serializable buffer.
PlatformSizeType FwSizeType
Serializable::SizeType getSize() const override
Get current buffer size.
static const FwSignedSizeType CRC_FILE_READ_BLOCK
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
void fill()
Fill the buffer to capacity with preexisting data.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
crc_stat_t create_checksum_file(const char *const fname)
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
crc_stat_t read_crc32_from_file(const char *const fname, U32 &checksum_from_file)
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
void close() override
close the file, if not opened then do nothing
Status write(const U8 *buffer, FwSizeType &size)
write data to this file from the supplied buffer bounded by size
A generic interface for creating and comparing hash values.
const char * toChar() const
Convert to a C-style char*.
crc_stat_t verify_checksum(const char *const fname, U32 &expected, U32 &actual)
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
uint8_t U8
8-bit unsigned integer
static Status getFileSize(const char *path, FwSizeType &size)
Get the size of the file (in bytes) at the specified path.
Status read(U8 *buffer, FwSizeType &size)
read data from this file into supplied buffer bounded by size
Operation was successful.
filename + hash extension does not fit in Fw::FileNameString
Operation was successful.
void finalize(HashBuffer &buffer) const
FormatStatus
status of string format calls