22 "Cannot use CRC checker without full string formatting");
49 int_file_size = filesize;
61 for(i = 0; i < blocks; i++)
63 stat = f.
read(block_data, bytes_to_read);
70 hash.
update(block_data, static_cast<NATIVE_INT_TYPE>(bytes_to_read));
74 bytes_to_read = remaining_bytes;
75 if(remaining_bytes > 0)
77 stat = f.
read(block_data, bytes_to_read);
84 hash.
update(block_data, static_cast<NATIVE_INT_TYPE>(remaining_bytes));
104 bytes_to_write =
sizeof(checksum);
105 stat = f.
write(reinterpret_cast<U8*>(&checksum), bytes_to_write);
135 stat = f.
read(reinterpret_cast<U8*>(&checksum_from_file), checksum_from_file_size);
136 if(stat !=
Os::File::OP_OK || checksum_from_file_size !=
sizeof(checksum_from_file))
160 U32 checksum_from_file;
172 if(static_cast<FwSignedSizeType>(int_file_size) != filesize)
187 for(i = 0; i < blocks; i++)
189 stat = f.
read(block_data, bytes_to_read);
196 hash.
update(block_data, static_cast<NATIVE_INT_TYPE>(bytes_to_read));
200 bytes_to_read = remaining_bytes;
201 if(remaining_bytes > 0)
203 stat = f.
read(block_data, bytes_to_read);
210 hash.
update(block_data, remaining_bytes);
216 hash.
final(checksum);
224 if(checksum != checksum_from_file)
226 expected = checksum_from_file;
231 expected = checksum_from_file;
Status read(U8 *buffer, FwSignedSizeType &size)
read data from this file into supplied buffer bounded by size
PlatformIntType NATIVE_INT_TYPE
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)
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
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
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
C++-compatible configuration header for fprime configuration.
uint8_t U8
8-bit unsigned integer
Operation was successful.
void update(const void *const data, const NATIVE_INT_TYPE len)
PlatformSignedSizeType FwSignedSizeType
#define HASH_EXTENSION_STRING
static Status getFileSize(const char *path, FwSignedSizeType &size)
Get the size of the file (in bytes) at the specified path.
Operation was successful.
static const NATIVE_INT_TYPE CRC_FILE_READ_BLOCK
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
FormatStatus
status of string format calls