ftwin 0.8.10
ft_report.c File Reference

Text-based duplicate reporting functions. More...

#include "ft_report.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <apr_strings.h>
#include <apr_file_io.h>
#include "config.h"
#include "debug.h"
#include "ft_archive.h"
#include "ft_config.h"
#include "ft_file.h"
#include "human_size.h"
#include "napr_hash.h"
#include "napr_heap.h"
Include dependency graph for ft_report.c:

Go to the source code of this file.

Functions

int ft_chksum_cmp (const void *chksum1, const void *chksum2)
 Comparison function for sorting checksums.
 
static apr_status_t process_and_report_duplicates_for_file (ft_conf_t *conf, ft_fsize_t *fsize, apr_size_t i, const reporting_colors_t *colors)
 Processes a single file to find and report its duplicates.
 
apr_status_t ft_report_duplicates (ft_conf_t *conf)
 Reports duplicate files in text format to stdout.
 
static apr_status_t get_comparison_paths (ft_conf_t *conf, ft_file_t *file_i, ft_file_t *file_j, char **fpathi, char **fpathj)
 Gets the file paths for comparison, handling archive extraction if needed.
 
static void cleanup_comparison_paths (ft_conf_t *conf, ft_file_t *file_i, ft_file_t *file_j, char *fpathi, char *fpathj)
 Cleans up temporary files created during archive extraction.
 
static void format_and_print_duplicate (ft_conf_t *conf, const ft_file_t *file, const reporting_colors_t *colors)
 Formats and prints the output for a duplicate file entry.
 

Detailed Description

Text-based duplicate reporting functions.

Definition in file ft_report.c.

Function Documentation

◆ ft_chksum_cmp()

int ft_chksum_cmp ( const void *  chksum1,
const void *  chksum2 
)

Comparison function for sorting checksums.

Parameters
chksum1First checksum to compare.
chksum2Second checksum to compare.
Returns
Negative if chksum1 < chksum2, 0 if equal, positive if chksum1 > chksum2.

Definition at line 40 of file ft_report.c.

Referenced by ft_report_duplicates(), and ft_report_json().

Here is the caller graph for this function:

◆ ft_report_duplicates()

apr_status_t ft_report_duplicates ( ft_conf_t conf)

Reports duplicate files in text format to stdout.

Parameters
confThe configuration structure containing file information.
Returns
APR_SUCCESS on success, or an error code.

Definition at line 100 of file ft_report.c.

References DEBUG_ERR, ft_chksum_cmp(), napr_hash_search(), napr_heap_extract(), and process_and_report_duplicates_for_file().

Referenced by ftwin_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_comparison_paths()

static apr_status_t get_comparison_paths ( ft_conf_t conf,
ft_file_t *  file_i,
ft_file_t *  file_j,
char **  fpathi,
char **  fpathj 
)
static

Gets the file paths for comparison, handling archive extraction if needed.

Returns
APR_SUCCESS on success, or an error status if extraction fails.

Definition at line 149 of file ft_report.c.

◆ process_and_report_duplicates_for_file()

static apr_status_t process_and_report_duplicates_for_file ( ft_conf_t conf,
ft_fsize_t *  fsize,
apr_size_t  i,
const reporting_colors_t colors 
)
static

Processes a single file to find and report its duplicates.

This helper function is called by ft_report_duplicates. It iterates through the checksum array for a given file size, compares subsequent files with the same hash, and calls compare_and_report_pair to verify and report true duplicates. This simplifies the main reporting loop by encapsulating the logic for handling a single file's potential duplicates.

Returns
APR_SUCCESS on success, or an error status if reporting fails.

Definition at line 71 of file ft_report.c.

Referenced by ft_report_duplicates().

Here is the caller graph for this function: