lib/util_hash.c: add xbps_file_hash_raw method

this function does not mmap the target file and therefore
avoids out of memory exceptions on 32bit systems.
This commit is contained in:
Enno Boland
2016-06-15 23:21:29 +02:00
parent 0b96156b5e
commit 7ce66edc57
2 changed files with 35 additions and 9 deletions

View File

@@ -1795,6 +1795,17 @@ bool xbps_mmap_file(const char *file, void **mmf, size_t *mmflen, size_t *filele
*/
char *xbps_file_hash(const char *file);
/**
* Returns a raw byte buffer with the sha256 hash for the file specified
* by \a file.
*
* @param[in] file Path to a file.
* @return A pointer to a malloc(3)ed buffer, NULL otherwise and errno
* is set appropiately. The pointer should be free(3)d when it's no
* longer needed.
*/
unsigned char *xbps_file_hash_raw(const char *file);
/**
* Compares the sha256 hash of the file \a file with the sha256
* string specified by \a sha256.