ftwin 0.8.10
ft_file.h File Reference

Interface for file comparison and checksum calculation. More...

#include <apr_pools.h>
#include "checksum.h"
Include dependency graph for ft_file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

apr_status_t checksum_file (const char *filename, apr_off_t size, apr_off_t excess_size, ft_hash_t *hash_out, apr_pool_t *gc_pool)
 Calculates the XXH128 checksum of a file.
 
apr_status_t filecmp (apr_pool_t *pool, const char *fname1, const char *fname2, apr_off_t size, apr_off_t excess_size, int *result_out)
 Compares two files byte-by-byte to determine if they are identical.
 

Detailed Description

Interface for file comparison and checksum calculation.

Definition in file ft_file.h.

Function Documentation

◆ checksum_file()

apr_status_t checksum_file ( const char *  filename,
apr_off_t  size,
apr_off_t  excess_size,
ft_hash_t hash_out,
apr_pool_t *  gc_pool 
)

Calculates the XXH128 checksum of a file.

This function handles both small files (using memory-mapping for efficiency if possible) and large files (using buffered reading). The determination is based on the excess_size parameter.

Parameters
[in]filenameThe path to the file.
[in]sizeThe size of the file.
[in]excess_sizeThe file size threshold above which buffered reading is used instead of mmap.
[out]hash_outPointer to a ft_hash_t structure to store the resulting checksum.
[in]gc_poolAn APR pool for temporary allocations during the operation.
Returns
APR_SUCCESS on success, or an APR error code on failure.

Definition at line 134 of file ft_file.c.

◆ filecmp()

apr_status_t filecmp ( apr_pool_t *  pool,
const char *  fname1,
const char *  fname2,
apr_off_t  size,
apr_off_t  excess_size,
int *  result_out 
)

Compares two files byte-by-byte to determine if they are identical.

This function intelligently chooses between memory-mapping for smaller files and buffered reading for larger files, based on the excess_size threshold.

Parameters
[in]poolThe APR pool to use for allocations.
[in]fname1The path to the first file.
[in]fname2The path to the second file.
[in]sizeThe size of the files (assumed to be identical).
[in]excess_sizeThe file size threshold to switch from mmap to buffered I/O.
[out]iPointer to an integer that will be set to 0 if the files are identical, or a non-zero value otherwise.
Returns
APR_SUCCESS on successful comparison, or an APR error code if a file cannot be read.

Definition at line 285 of file ft_file.c.

Referenced by ft_report_json().

Here is the caller graph for this function: