LCOV - code coverage report
Current view: top level - src - file_compare_metadata_equivalence.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.8 % 16 15
Test Date: 2026-03-01 04:31:48 Functions: 100.0 % 1 1
Branches: 88.9 % 18 16

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Checks whether key file metadata changed since the last crawl.
       5                 :             :  *
       6                 :             :  * Compares data from the FTS library file traversal with the stat
       7                 :             :  * structure stored in SQLite from the previous probe.
       8                 :             :  *
       9                 :             :  * @param source                Source file stat structure
      10                 :             :  * @param destination   Destination file stat structure
      11                 :             :  *
      12                 :             :  * @return Return status:
      13                 :             :  *         - IDENTICAL: Files are identical
      14                 :             :  *         - COMPARE_FAILED: Error in comparison or invalid parameters
      15                 :             :  *         - SIZE_CHANGED (logical file size changed)
      16                 :             :  *         - ALLOCATED_SIZE_CHANGED (allocated block count changed)
      17                 :             :  *         - MODIFICATION_TIME_CHANGED
      18                 :             :  *         - STATUS_CHANGED_TIME
      19                 :             :  */
      20                 :        1372 : Changed file_compare_metadata_equivalence(
      21                 :             :         const CmpctStat *source,
      22                 :             :         const CmpctStat *destination)
      23                 :             : {
      24                 :             :         /* Validate input parameters */
      25   [ +  -  -  + ]:        1372 :         if(NULL == source || NULL == destination)
      26                 :             :         {
      27                 :           0 :                 return(COMPARE_FAILED);
      28                 :             :         }
      29                 :             : 
      30                 :        1372 :         Changed changes = IDENTICAL;
      31                 :             : 
      32                 :             :         /* Logical file size in bytes. */
      33         [ +  + ]:        1372 :         if(source->st_size != destination->st_size)
      34                 :             :         {
      35                 :          82 :                 changes |= SIZE_CHANGED;
      36                 :             :         }
      37                 :             : 
      38                 :             :         /* Allocated size of file in POSIX 512-byte blocks. */
      39                 :             : #if 0
      40                 :             :         if(source->st_blocks != destination->st_blocks)
      41                 :             : #else
      42                 :             :         /* This legacy can be removed in 2036 (10-year Long-Term Support) */
      43         [ +  + ]:        1372 :         if(source->st_blocks != BLKCNT_UNKNOWN
      44         [ +  + ]:        1252 :                 && source->st_blocks != destination->st_blocks)
      45                 :             : #endif
      46                 :             :         {
      47                 :          28 :                 changes |= ALLOCATED_SIZE_CHANGED;
      48                 :             :         }
      49                 :             : 
      50                 :             :         /* Modified timestamp */
      51         [ +  + ]:        1372 :         if(!(source->mtim_tv_sec == destination->mtim_tv_sec &&
      52         [ +  + ]:        1172 :                 source->mtim_tv_nsec == destination->mtim_tv_nsec))
      53                 :             :         {
      54                 :         272 :                 changes |= MODIFICATION_TIME_CHANGED;
      55                 :             :         }
      56                 :             : 
      57                 :             :         /* Time of last status change  */
      58         [ +  + ]:        1372 :         if(!(source->ctim_tv_sec == destination->ctim_tv_sec &&
      59         [ +  + ]:        1250 :                 source->ctim_tv_nsec == destination->ctim_tv_nsec))
      60                 :             :         {
      61                 :         280 :                 changes |= STATUS_CHANGED_TIME;
      62                 :             :         }
      63                 :             : 
      64                 :        1372 :         return(changes);
      65                 :             : }
        

Generated by: LCOV version 2.0-1