#include <opennurbs_file_utilities.h>
|
static int | Compare (const ON_ContentHash &a, const ON_ContentHash &b) |
|
static int | CompareContent (const ON_ContentHash &a, const ON_ContentHash &b) |
|
static ON_ContentHash::CompareResult | CompareResultFromUnsigned (unsigned int compare_result_as_unsigned) |
|
static ON_ContentHash | Create (ON_SHA1_Hash sha1_name_hash, ON__UINT64 byte_count, ON_SHA1_Hash sha1_content_hash, ON__UINT64 hash_time, ON__UINT64 content_last_modified_time) |
|
static ON_ContentHash | CreateFromBuffer (ON_SHA1_Hash sha1_name_hash, const void *buffer, size_t byte_count) |
|
static ON_ContentHash | CreateFromFile (const char *filename) |
|
static ON_ContentHash | CreateFromFile (const wchar_t *filename) |
|
static ON_ContentHash | CreateFromFile (ON_SHA1_Hash sha1_file_name_hash, FILE *fp) |
|
static bool | DifferentContent (const ON_ContentHash &a, const ON_ContentHash &b) |
|
static bool | EqualContent (const ON_ContentHash &a, const ON_ContentHash &b) |
|
◆ CompareResult
ON_ContentHash::Compare are the possible results of calling ON_ContentHash::CompareFile().
Enumerator |
---|
Unset | Not set. This value is never returned by ON_ContentHash::CheckFile().
|
EqualContent | File exists and its size and content matches the information used to set the content hash.
|
DifferentContent | File exists and its size or content differs from the information used to set the content hash. Unable to reliably determine which is newer.
|
DifferentContentFileIsOlder | File exists and its size or content differs from the information used to set the content hash. The file's last modified time is older than ContentLastModifiedTime().
|
ContentDifferentFileIsNewer | File exists and its size or content differs from the information used to set the content hash. The file's last modified time is newer than ContentLastModifiedTime().
|
FileDoesNotExist | File does not exist.
|
FileSystemFailure | File cannot be opened, read, or some other file system issue prevents checking.
|
◆ ON_ContentHash() [1/2]
ON_ContentHash::ON_ContentHash |
( |
| ) |
|
|
default |
◆ ~ON_ContentHash()
ON_ContentHash::~ON_ContentHash |
( |
| ) |
|
|
default |
◆ ON_ContentHash() [2/2]
◆ ByteCount()
Returns: Number of bytes in the content (typically a file or buffer).
◆ Compare() [1/3]
Description: Compares all fields
◆ Compare() [2/3]
◆ Compare() [3/3]
◆ CompareContent()
Description: Compares content byte count and content SHA-1
◆ CompareResultFromUnsigned()
◆ ContentHash()
Returns: SHA-1 hash of the content (typically a buffer or file).
◆ ContentLastModifiedTime()
ON__UINT64 ON_ContentHash::ContentLastModifiedTime |
( |
| ) |
const |
Returns: Time the hashed content was last modified in seconds since January 1, 1970 UCT. 0 is returned if this time is not known.
This time should be used for important decisions as a last resort.
When hash values differ, this time may be considered to which content is newer (or most recently copied).
Unfortunately, in many cases this time is often unknown and incorrectly set. For example, some file systems set the last modified time of a copy of an "old" file to the time the copy was created. Thus a copy of "old" content may appear to be newer than "new" content that has not been copied.
◆ Create()
Description: Create an ON_ContentHash class with the specified size, hash and times. Parameters: sha1_name_hash - [in] The SHA-1 hash of the name (typically a full path file name). When the content is identified by a file name in a file system, use ON_SHA1_Hash::FileSystemPathHash() to calculate this value. byte_count - [in] number of bytes in the content. sha1_content_hash - [in] The SHA-1 hash of the content (typically a buffer or file). You may use ON_SHA1_Has::FileContentHash() or ON_SHA1_Hash::BufferContentHash() to calculate this value. hash_time - [in] The time the sha1_hash was calculated in seconds since January 1, 1970 UCT. If 0 is passed in, the current time is used. content_last_modified_time - [in] Pass 0 if not known. The time the hashed information that was last modified in seconds since January 1, 1970 UCT. If content_last_modified_time > hash_time, then 0 is used. Returns: An ON_ContentHash with size and SHA-1 hash and times set from the parameters,
◆ CreateFromBuffer()
Description: Create an ON_ContentHash from a memory buffer. Parameters: sha1_name_hash - [in] A SHA-1 hash of the name associated with this content. If the buffer has no name, pass ON_SHA1_Hash::ZeroDigest. If the buffer has an empty name, pass ON_SHA1_Hash::EmptyContentHash. buffer - [in]
byte_count - [in] number of bytes in buffer[] Returns: An ON_ContentHash with size and SHA-1 hash calculated from the parameters, hash time = now, and content last modified time = 0.
◆ CreateFromFile() [1/3]
static ON_ContentHash ON_ContentHash::CreateFromFile |
( |
const char * |
filename | ) |
|
|
static |
◆ CreateFromFile() [2/3]
static ON_ContentHash ON_ContentHash::CreateFromFile |
( |
const wchar_t * |
filename | ) |
|
|
static |
◆ CreateFromFile() [3/3]
Description: Create an ON_ContentHash from a file stream. Parameters: sha1_file_name_hash - [in] A SHA-1 hash of the file name associated with fp. Use ON_SHA1_Has::FileSystemPathHash() to create the value. If the name is not known, pass ON_SHA1_Hash::ZeroDigest. fp - [in] pointer to a file opened with ON:FileOpen(...,"rb") Returns: An ON_ContentHash with size and SHA-1 hash and times set from the file, hash time = now, and content last modified time set from the file system information returned by ON_FileStream::GetFileInformation().
◆ DifferentContent()
Returns: true if a and b have different ByteCount() or SHA-1 content hash values.
◆ Dump()
void ON_ContentHash::Dump |
( |
class ON_TextLog & |
text_log | ) |
const |
◆ EqualContent()
Returns: true if a and b have identical ByteCount() and SHA-1 content hash values.
◆ EqualFileNameSizeAndTime()
bool ON_ContentHash::EqualFileNameSizeAndTime |
( |
const wchar_t * |
filename | ) |
const |
Parameters: filename - [in] Returns: True if the file exists, has size > 0, has the same name, same size, and same last modified time than this content hash. False otherwise. Remarks: Faster than the ON_ContentHash::EqualContent() and reliable if this content hash was set on the same file system. Unreliable if the file system does not correctly set last modified times or the file was modified less than 2 seconds before the call.
◆ HashCalculationTime()
ON__UINT64 ON_ContentHash::HashCalculationTime |
( |
| ) |
const |
Returns: Time the hash SHA-1 hash was calculated in seconds since January 1, 1970 UCT.
◆ IsNotSet()
bool ON_ContentHash::IsNotSet |
( |
| ) |
const |
Returns: True if the SHA-1 hash is not set.
◆ IsSameBufferContent()
bool ON_ContentHash::IsSameBufferContent |
( |
const void * |
buffer, |
|
|
size_t |
byte_count |
|
) |
| const |
Description: Test a buffer to see if it has a matching size and SHA-1 hash. Parameters: buffer - [in]
byte_count - [in] number of bytes in buffer[] Returns: True if the buffer has a matching byte_count and SHA-1 hash.
◆ IsSameFileContent() [1/3]
bool ON_ContentHash::IsSameFileContent |
( |
const char * |
filename | ) |
const |
◆ IsSameFileContent() [2/3]
bool ON_ContentHash::IsSameFileContent |
( |
const wchar_t * |
filename | ) |
const |
Description: Test a file to see if it has a matching size and SHA-1 content hash. Parameters: filename - [in] Returns: True if the file exists, can be read, and has a matching byte_count and SHA-1 content hash.
◆ IsSameFileContent() [3/3]
bool ON_ContentHash::IsSameFileContent |
( |
FILE * |
fp | ) |
const |
Description: Test a file to see if it has a matching size and SHA-1 hash. Parameters: fp - [in] pointer to file opened with ON::OpenFile(...,"rb") bSkipTimeCheck - [in] if true, the time of last modification is not checked. Returns: True if the file exists, can be read, and has a matching byte_count and SHA-1 hash.
◆ IsSet()
bool ON_ContentHash::IsSet |
( |
| ) |
const |
Returns: True if the SHA-1 hash has been set.
◆ NameHash()
Returns: SHA-1 hash of the name (typically a full path file name).
◆ operator=()
◆ Read()
◆ Write()
◆ Unset