Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
42 lines (35 loc) · 940 Bytes

File metadata and controls

42 lines (35 loc) · 940 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "path_utils.h"
#include <unistd.h>
String get_executable_path()
{
String result = talloc_string(PATH_MAX);
memset(result.data, 0, sizeof(PATH_MAX));
auto size_wrote = readlink("/proc/self/exe", (char*)result.data, PATH_MAX);
if (size_wrote == -1)
{
fprintf(stderr, "Couldn't get the path to running exe...\n");
exit(1);
}
result.count = size_wrote;
return result;
}
void setcwd(String dir)
{
if (dir)
{
char *c_string_dir = (char*)temp_c_string(dir);
// printf("cd to '%s'\n", c_string_dir);
i32 success = chdir(c_string_dir);
if (success == -1)
{
fprintf(stderr, "Cannot cd to '%s'...\n", c_string_dir);
assert(0);
}
reset_temporary_storage();
}
else
{
fprintf(stderr, "The directory of the executable is NULL. Cannot chdir() there...\n");
assert(0);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.