MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / find_yourself

Function find_yourself

src/utils/FindBinary.h:45–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45int find_yourself(char *result,
46 size_t size_of_result)
47{
48#if (!defined(_WIN32) || !defined(_WIN64))
49 char newpath[PATH_MAX + 256];
50 char newpath2[PATH_MAX + 256];
51
52 assert(findyourself_initialized);
53 result[0] = 0;
54
55 if (findyourself_save_argv0[0] == findyourself_path_separator)
56 {
57 if (findyourself_debug)
58 {
59 printf(" absolute path\n");
60 }
61
62 realpath(findyourself_save_argv0, newpath);
63
64 if (findyourself_debug)
65 {
66 printf(" newpath=\"%s\"\n", newpath);
67 }
68
69 if (!access(newpath, F_OK))
70 {
71 strncpy(result, newpath, size_of_result);
72 result[size_of_result - 1] = 0;
73 return 0;
74 }
75 else
76 {
77 perror("access failed 1");
78 }
79 }
80 else if ( strchr(findyourself_save_argv0, findyourself_path_separator))
81 {
82 if (findyourself_debug)
83 {
84 printf(" relative path to pwd\n");
85 }
86
87 strncpy(newpath2, findyourself_save_pwd, sizeof(newpath2));
88 newpath2[sizeof(newpath2) - 1] = 0;
89 strncat(newpath2, findyourself_path_separator_as_string, sizeof(newpath2) - strlen(newpath2) - 1);
90 newpath2[sizeof(newpath2) - 1] = 0;
91 strncat(newpath2, findyourself_save_argv0, sizeof(newpath2) - strlen(newpath2) - 1);
92 newpath2[sizeof(newpath2) - 1] = 0;
93 realpath(newpath2, newpath);
94
95 if (findyourself_debug)
96 {
97 printf(" newpath=\"%s\"\n", newpath);
98 }
99
100 if (!access(newpath, F_OK))
101 {
102 strncpy(result, newpath, size_of_result);

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected