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-01-12 05:34:38 Functions: 100.0 % 1 1

            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          202 : Return determine_running_dir(void)
       8              : {
       9          202 :         char *cwd = NULL;
      10              : 
      11              : #if defined(__GLIBC__)
      12          202 :         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          202 :         if(cwd != NULL)
      19              :         {
      20          202 :                 remove_trailing_slash(cwd);
      21          202 :                 config->running_dir = cwd;
      22          202 :                 config->running_dir_size = (long int)strlen(config->running_dir) + 1;
      23          202 :                 slog(TRACE,"Current directory: %s\n",config->running_dir);
      24          202 :                 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