Includes functions to generate and check a hash for a given file. More...
Enumerations | |
enum | ErrorValue { kErr_OK, kErr_FileNotFound, kErr_OpenFailed, kErr_ReadFailed, kErr_HashNotFound, kErr_HashFound, kErr_HashMismatch, kErr_InvalidParam } |
Possible error return values. More... | |
enum | ExpectHash { kEH_ExpectNoHash, kEH_ExpectHash } |
Functions | |
ErrorValue | generateHashForFile (const char *lpFileName, Hash *lpHashOut) |
Writes a hash value for the data in the given file to the pointer. | |
ErrorValue | generateTaggedHashForFile (const char *lpFileName, const char *lpTag, Hash *lpHashOut) |
Writes a hash value for the specified tag string and data in the given file to the pointer. | |
ErrorValue | generateTaggedHashForNodeName (const char *lpNodeName, const char *lpTag, Hash *lpHashOut) |
Writes a hash value for the specified tag string and node name to the pointer. | |
ErrorValue | checkSpecifiedHashWithFile (const char *lpFileName, Hash lExpectedHash) |
ErrorValue | checkEmbeddedHashInFile (const char *lpFileName) |
Checks that the hash value stored in the given file is correct. | |
ErrorValue | embedHashInFile (const char *lpFileName, Hash lHash) |
ErrorValue | embedHashInFile (const char *lpFileName) |
const char * | getErrorMessage (ErrorValue lErrorValue) |
Returns an appropriate error string for the given error value. | |
ErrorValue | generateHashForOpenFile (FILE *lpFile, size_t lBytesToRead, Hash *lpHashOut, ExpectHash lExpectHash) |
ErrorValue | generateTaggedHashForOpenFile (FILE *lpFile, size_t lBytesToRead, const char *lpTag, Hash *lpHashOut, ExpectHash lExpectHash) |
ErrorValue | fileContainsHash (FILE *lpFile) |
Debug | |
These functions are only valid in debug mode, and indicate the last hashes used in various contexts. In release mode they will just return uninitialised hashes. | |
Hash | lastEmbeddedHash () |
Hash | lastDetectedHash () |
Hash | lastGeneratedHash () |
Variables | |
const size_t | kBufferSize |
const U32 | kHashMarker |
Hash | sLastEmbeddedHash |
Hash | sLastDetectedHash |
Hash | sLastGeneratedHash |
Includes functions to generate and check a hash for a given file.
Possible error return values.
Enumerator | |
---|---|
kErr_OK |
No problems. |
kErr_FileNotFound |
File couldn't be opened - not found. |
kErr_OpenFailed |
File couldn't be opened - any other error (including sharing) |
kErr_ReadFailed |
Couldn't read all expected data. |
kErr_HashNotFound |
File doesn't contain a hash value (and we expected one) |
kErr_HashFound |
File contains a hash value (and we didn't expect one) |
kErr_HashMismatch |
Hash found, but doesn't match the expected value. |
kErr_InvalidParam |
Parameter invalid - e. g. null pointer. |
ErrorValue DD::Image::HashFile::checkSpecifiedHashWithFile | ( | const char * | lpFileName, |
Hash | lExpectedHash | ||
) |
Checks that the hash value for the data in the file matches the given value. This expects that the file does not have a hash embedded
References generateHashForFile(), kErr_HashMismatch, and kErr_OK.
ErrorValue DD::Image::HashFile::embedHashInFile | ( | const char * | lpFileName, |
Hash | lHash | ||
) |
Embeds the hash in the file, appending to it directly. It returns an error if a hash is already present
References kErr_FileNotFound, kErr_OK, kErr_OpenFailed, and kErr_ReadFailed.
Referenced by embedHashInFile().
ErrorValue DD::Image::HashFile::embedHashInFile | ( | const char * | lpFileName | ) |
Embeds the hash in the file, appending to it directly. This version generates the hash from the file first
References embedHashInFile(), generateHashForFile(), and kErr_OK.
©2021 The Foundry Visionmongers, Ltd. All Rights Reserved. |