xxHash64 file hashing function implementation.
More...
#include "xx.h"
#include <assert.h>
#include <stdio.h>
#include "xxHash/xxhash.h"
#include "fs.h"
|
static uint64_t | xxhash (uint8_t *b, FILE *f) |
| Computes the xxHash64 hash of the data read from the given file using a buffer for reading. The file is read in chunks until EOF.
|
|
static uint64_t | xxhashfp (uint8_t *b, const char *fp) |
| Computes the xxHash64 hash of the file located at the given filepath. The file is opened, read in chunks until EOF, and then closed.
|
|
uint64_t | xxupdate (const struct xxreq_s *req) |
| Processes a file hash request. If the file's last modified time or size differ from the previous stat info pst , the file is re-hashed and the current hash value is returned. Otherwise the previous pxx hash value is returned indicating no change.
|
|
xxHash64 file hashing function implementation.
◆ xxhash()
static uint64_t xxhash |
( |
uint8_t * |
b, |
|
|
FILE * |
f |
|
) |
| |
|
static |
Computes the xxHash64 hash of the data read from the given file using a buffer for reading. The file is read in chunks until EOF.
- Parameters
-
b | Buffer for reading file data. Must not be NULL. |
f | FILE object to read data from. Must not be NULL. The file should be opened in binary mode and positioned at the start of the data. |
- Returns
- Hash value of the file data, or 0 if an error occurred.
◆ xxhashfp()
static uint64_t xxhashfp |
( |
uint8_t * |
b, |
|
|
const char * |
fp |
|
) |
| |
|
static |
Computes the xxHash64 hash of the file located at the given filepath. The file is opened, read in chunks until EOF, and then closed.
- Parameters
-
b | Buffer for reading file data. Must not be NULL. |
fp | The filepath of the file to hash. Must not be NULL. |
- Returns
- The hash value of the file, or 0 if an error occurred (e.g. file could not be opened).
◆ xxupdate()
uint64_t xxupdate |
( |
const struct xxreq_s * |
req | ) |
|
Processes a file hash request. If the file's last modified time or size differ from the previous stat info pst
, the file is re-hashed and the current hash value is returned. Otherwise the previous pxx
hash value is returned indicating no change.
- Parameters
-
req | The file hash request structure containing the filepath, previous and current stat info, and previous hash value (if known). |
- Returns
- 0 if an error occurred, otherwise the current hash value.