48 int_file_size = filesize;
60 for(i = 0; i < blocks; i++)
62 stat = f.
read(block_data, bytes_to_read);
73 bytes_to_read = remaining_bytes;
74 if(remaining_bytes > 0)
76 stat = f.
read(block_data, bytes_to_read);
103 bytes_to_write =
sizeof(checksum);
104 stat = f.
write(
reinterpret_cast<U8*
>(&checksum), bytes_to_write);
134 stat = f.
read(
reinterpret_cast<U8*
>(&checksum_from_file), checksum_from_file_size);
135 if(stat !=
Os::File::OP_OK || checksum_from_file_size !=
sizeof(checksum_from_file))
159 U32 checksum_from_file;
186 for(i = 0; i < blocks; i++)
188 stat = f.
read(block_data, bytes_to_read);
199 bytes_to_read = remaining_bytes;
200 if(remaining_bytes > 0)
202 stat = f.
read(block_data, bytes_to_read);
209 hash.
update(block_data, remaining_bytes);
215 hash.
final(checksum);
223 if(checksum != checksum_from_file)
225 expected = checksum_from_file;
230 expected = checksum_from_file;
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
#define HASH_EXTENSION_STRING
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
PlatformSignedSizeType FwSignedSizeType
C++-compatible configuration header for fprime configuration.
Status read(U8 *buffer, FwSignedSizeType &size)
read data from this file into supplied buffer bounded by size
void close() override
close the file, if not opened then do nothing
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
@ OP_OK
Operation was successful.
@ OPEN_WRITE
Open file for writing.
@ OPEN_READ
Open file for reading.
static Status getFileSize(const char *path, FwSignedSizeType &size)
Get the size of the file (in bytes) at the specified path.
@ OP_OK
Operation was successful.
A generic interface for creating and comparing hash values.
void update(const void *const data, const NATIVE_INT_TYPE len)
void final(HashBuffer &buffer)
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