35 while( cnt <= max_itr ) {
37 size =
sizeof(buffer);
38 status = file.
read(&buffer, size,
false);
47 hash.
update(&buffer, size);
58 hash.
final(computedHashBuffer);
59 hashBuffer = computedHashBuffer;
78 status = hashFile.
read(&savedHash[0], size);
89 hashBuffer = savedHashBuffer;
175 return validate(fileName, hashFileName, hashBuffer);
184 status =
readHash(hashFileName, savedHash);
197 if( savedHash != computedHash ){
201 hashBuffer = savedHash;
216 status =
writeHash(hashFileName, hashBuffer);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
#define HASH_DIGEST_LENGTH
PlatformSizeType FwSizeType
Defines a file class to validate files or generate a file validator file.
#define VFILE_HASH_CHUNK_SIZE
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
@ DOESNT_EXIST
File doesn't exist (for read)
@ NOT_OPENED
file hasn't been opened yet
@ BAD_SIZE
Invalid size parameter.
@ OTHER_ERROR
A catch-all for other errors. Have to look in implementation-specific code.
@ NO_PERMISSION
No permission to read/write file.
@ 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 container class for holding a hash buffer.
NATIVE_UINT_TYPE getBuffCapacity() const
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.
@ FILE_NO_PERMISSION
No permission to read/write file.
@ VALIDATION_OK
The validation of the file passed.
@ VALIDATION_FILE_DOESNT_EXIST
Validation file doesn't exist (for read)
@ FILE_DOESNT_EXIST
File doesn't exist (for read)
@ VALIDATION_FAIL
The validation of the file did not pass.
@ OTHER_ERROR
A catch-all for other errors. Have to look in implementation-specific code.
@ FILE_BAD_SIZE
Invalid size parameter.
@ NO_SPACE
No space left on the device for writing.
@ VALIDATION_FILE_BAD_SIZE
Invalid size parameter.
@ VALIDATION_FILE_NO_PERMISSION
No permission to read/write file.
Status createValidation(const char *fileName, const char *hash, Utils::HashBuffer &hashBuffer)
Status validate(const char *fileName, const char *hashFileName, Utils::HashBuffer &hashBuffer)
Validate the contents of a file 'fileName' against its hash.
File::Status computeHash(const char *fileName, Utils::HashBuffer &hashBuffer)
File::Status readHash(const char *hashFileName, Utils::HashBuffer &hashBuffer)
File::Status writeHash(const char *hashFileName, Utils::HashBuffer hashBuffer)
ValidateFile::Status translateStatus(File::Status status, StatusFileType type)