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 : }
|