LCOV - code coverage report
Current view: top level - src - determine_running_dir.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 81.8 % 11 9
Test Date: 2026-03-01 04:31:48 Functions: 100.0 % 1 1
Branches: 50.0 % 2 1

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * Save the runtime directory absolute path into global config structure,
       5                 :             :  * fopen() was not able to process relative paths, only absolute ones.
       6                 :             :  */
       7                 :         325 : Return determine_running_dir(void)
       8                 :             : {
       9                 :         325 :         char *cwd = NULL;
      10                 :             : 
      11                 :             : #if defined(__GLIBC__)
      12                 :         325 :         cwd = get_current_dir_name();
      13                 :             : #else
      14                 :             :         // Portable fallback for platforms without get_current_dir_name (e.g., macOS)
      15                 :             :         cwd = getcwd(NULL,0);
      16                 :             : #endif
      17                 :             : 
      18         [ +  - ]:         325 :         if(cwd != NULL)
      19                 :             :         {
      20                 :         325 :                 remove_trailing_slash(cwd);
      21                 :         325 :                 config->running_dir = cwd;
      22                 :         325 :                 config->running_dir_size = (long int)strlen(config->running_dir) + 1;
      23                 :         325 :                 slog(TRACE,"Current directory: %s\n",config->running_dir);
      24                 :         325 :                 provide(SUCCESS);
      25                 :             :         } else {
      26                 :           0 :                 slog(ERROR,"Error getting current directory\n");
      27                 :           0 :                 provide(FAILURE);
      28                 :             :         }
      29                 :             : }
        

Generated by: LCOV version 2.0-1