49 if(
static_cast<FwSizeType>(int_file_size) != filesize)
64 for(i = 0; i < blocks; i++)
66 stat = f.
read(block_data, bytes_to_read);
73 hash.
update(block_data, bytes_to_read);
77 bytes_to_read = remaining_bytes;
78 if(remaining_bytes > 0)
80 stat = f.
read(block_data, bytes_to_read);
87 hash.
update(block_data, remaining_bytes);
107 bytes_to_write =
sizeof(checksum);
108 stat = f.
write(
reinterpret_cast<U8*
>(&checksum), bytes_to_write);
138 stat = f.
read(
reinterpret_cast<U8*
>(&checksum_from_file), checksum_from_file_size);
139 if(stat !=
Os::File::OP_OK || checksum_from_file_size !=
sizeof(checksum_from_file))
163 U32 checksum_from_file;
175 if(
static_cast<FwSizeType>(int_file_size) != filesize)
190 for(i = 0; i < blocks; i++)
192 stat = f.
read(block_data, bytes_to_read);
199 hash.
update(block_data, bytes_to_read);
203 bytes_to_read = remaining_bytes;
204 if(remaining_bytes > 0)
206 stat = f.
read(block_data, bytes_to_read);
213 hash.
update(block_data, remaining_bytes);
219 hash.
final(checksum);
227 if(checksum != checksum_from_file)
229 expected = checksum_from_file;
234 expected = checksum_from_file;
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
#define HASH_EXTENSION_STRING
PlatformSizeType FwSizeType
C++-compatible configuration header for fprime configuration.
@ OP_OK
Operation was successful.
Status write(const void *buffer, NATIVE_INT_TYPE &size, bool waitForDone=true)
write size; will return amount written or errno
@ OPEN_WRITE
Open file for writing.
@ OPEN_READ
Open file for reading.
Status open(const char *fileName, Mode mode)
open file. Writing creates file if it doesn't exist
Status read(void *buffer, NATIVE_INT_TYPE &size, bool waitForFull=true)
waitForFull = true to wait for all bytes to be read
A generic interface for creating and comparing hash values.
void update(const void *const data, const NATIVE_INT_TYPE len)
void final(HashBuffer &buffer)
Status getFileSize(const char *path, FwSizeType &size)
append file origin to destination file. If boolean true, creates a brand new file if the destination ...
@ OP_OK
Operation was successful.
crc_stat_t read_crc32_from_file(const char *const fname, U32 &checksum_from_file)
crc_stat_t create_checksum_file(const char *const fname)
static const U32 CRC_MAX_FILENAME_SIZE
crc_stat_t verify_checksum(const char *const fname, U32 &expected, U32 &actual)
static const NATIVE_INT_TYPE CRC_FILE_READ_BLOCK