22 "Cannot use CRC checker without full string formatting");
58 for(i = 0; i < blocks; i++)
60 stat = f.
read(block_data, bytes_to_read);
67 hash.
update(block_data, bytes_to_read);
71 bytes_to_read = remaining_bytes;
72 if(remaining_bytes > 0)
74 stat = f.
read(block_data, bytes_to_read);
81 hash.
update(block_data, remaining_bytes);
101 bytes_to_write =
sizeof(checksum);
102 stat = f.
write(reinterpret_cast<U8*>(&checksum), bytes_to_write);
132 stat = f.
read(reinterpret_cast<U8*>(&checksum_from_file), checksum_from_file_size);
133 if(stat !=
Os::File::OP_OK || checksum_from_file_size !=
sizeof(checksum_from_file))
157 U32 checksum_from_file;
177 for(i = 0; i < blocks; i++)
179 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)
193 stat = f.
read(block_data, bytes_to_read);
200 hash.
update(block_data, remaining_bytes);
206 hash.
final(checksum);
214 if(checksum != checksum_from_file)
216 expected = checksum_from_file;
221 expected = checksum_from_file;
void update(const void *const data, const FwSizeType len)
PlatformSizeType FwSizeType
static const FwSignedSizeType CRC_FILE_READ_BLOCK
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
void final(HashBuffer &buffer)
crc_stat_t create_checksum_file(const char *const fname)
crc_stat_t read_crc32_from_file(const char *const fname, U32 &checksum_from_file)
const char * toChar() const
#define FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING
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.
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.
#define HASH_EXTENSION_STRING
Operation was successful.
FormatStatus
status of string format calls