LCOV - code coverage report
Current view: top level - src - directory_access.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 83.3 % 12 10
Test Date: 2026-03-01 04:31:48 Functions: 100.0 % 1 1
Branches: 60.0 % 10 6

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Check directory accessibility and skip its subtree if needed.
       5                 :             :  *
       6                 :             :  * Builds an absolute path from runtime_root and the FTS entry, calls
       7                 :             :  * file_check_access and:
       8                 :             :  * - on success returns SUCCESS;
       9                 :             :  * - on denied/not found logs a message and sets FTS_SKIP (unless --include was specified);
      10                 :             :  * - on access error returns FAILURE.
      11                 :             :  *
      12                 :             :  * @param file_systems  FTS traversal handle.
      13                 :             :  * @param entry         Current FTS directory entry.
      14                 :             :  * @param runtime_root  Absolute traversal root without trailing slash.
      15                 :             :  * @param first_iteration  Banner sentinel for first visible output.
      16                 :             :  * @param summary       Traversal state used by slog_show() banners/flags.
      17                 :             :  * @return SUCCESS or FAILURE.
      18                 :             :  */
      19                 :        9988 : Return verify_directory_access(
      20                 :             :         FTS              *file_systems,
      21                 :             :         FTSENT           *entry,
      22                 :             :         const char       *runtime_root,
      23                 :             :         bool             *first_iteration,
      24                 :             :         TraversalSummary *summary)
      25                 :             : {
      26         [ -  + ]:        9988 :         if(runtime_root == NULL)
      27                 :             :         {
      28                 :           0 :                 return(SUCCESS);
      29                 :             :         }
      30                 :             : 
      31                 :        9988 :         const char *relative_path = extract_relative_path(entry->fts_path,runtime_root);
      32                 :             : 
      33                 :        9988 :         FileAccessStatus access_status = file_check_access(entry->fts_path,(size_t)entry->fts_pathlen,R_OK | X_OK);
      34                 :             : 
      35         [ -  + ]:        9988 :         if(access_status == FILE_ACCESS_ERROR)
      36                 :             :         {
      37                 :           0 :                 return(FAILURE);
      38                 :             :         }
      39                 :             : 
      40   [ +  +  -  + ]:        9988 :         if(access_status == FILE_ACCESS_DENIED || access_status == FILE_NOT_FOUND)
      41                 :             :         {
      42                 :           4 :                 slog_show(EVERY|UNDECOR|REMEMBER,false,first_iteration,summary,"inaccessible directory %s\n",relative_path);
      43                 :             : 
      44         [ +  - ]:           4 :                 if(config->include_specified == false)
      45                 :             :                 {
      46                 :           4 :                         (void)fts_set(file_systems,entry,FTS_SKIP);
      47                 :             :                 }
      48                 :             :         }
      49                 :             : 
      50                 :        9988 :         return(SUCCESS);
      51                 :             : }
        

Generated by: LCOV version 2.0-1