LCOV - code coverage report
Current view: top level - src - compare_file_metadata_equivalence.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 92.3 % 13 12
Test Date: 2026-01-12 05:34:38 Functions: 100.0 % 1 1

            Line data    Source code
       1              : #include "precizer.h"
       2              : 
       3              : /**
       4              :  * @brief Checks if the file's size, creation time, and modification time have
       5              :  *        not changed since the last crawl.
       6              :  *
       7              :  * Compares data from the FTS library file traversal with the stat
       8              :  * structure stored in SQLite from the previous probe.
       9              :  *
      10              :  * @param source                Source file stat structure
      11              :  * @param destination   Destination file stat structure
      12              :  *
      13              :  * @return Return status:
      14              :  *         - IDENTICAL: Files are identical
      15              :  *         - FAILURE: Error in comparison or invalid parameters
      16              :  *         - SIZE_CHANGED
      17              :  *         - MODIFICATION_TIME_CHANGED
      18              :  *         - STATUS_CHANGED_TIME
      19              :  */
      20         1002 : Changed compare_file_metadata_equivalence(
      21              :         const CmpctStat *source,
      22              :         const CmpctStat *destination)
      23              : {
      24              :         /* Validate input parameters */
      25         1002 :         if(NULL == source || NULL == destination)
      26              :         {
      27            0 :                 return(COMPARE_FAILED);
      28              :         }
      29              : 
      30         1002 :         Changed changes = IDENTICAL;
      31              : 
      32              :         /* Size of file, in bytes.  */
      33         1002 :         if(source->st_size != destination->st_size)
      34              :         {
      35           50 :                 changes |= SIZE_CHANGED;
      36              :         }
      37              : 
      38              :         /* Modified timestamp */
      39         1002 :         if(!(source->mtim_tv_sec == destination->mtim_tv_sec &&
      40          849 :                 source->mtim_tv_nsec == destination->mtim_tv_nsec))
      41              :         {
      42          206 :                 changes |= MODIFICATION_TIME_CHANGED;
      43              :         }
      44              : 
      45              :         /* Time of last status change  */
      46         1002 :         if(!(source->ctim_tv_sec == destination->ctim_tv_sec &&
      47          880 :                 source->ctim_tv_nsec == destination->ctim_tv_nsec))
      48              :         {
      49          208 :                 changes |= STATUS_CHANGED_TIME;
      50              :         }
      51              : 
      52         1002 :         return(changes);
      53              : }
        

Generated by: LCOV version 2.0-1