TheBrokenRail
48137f9665
Some checks failed
Build / Build (AMD64, Client) (push) Successful in 35m5s
Build / Build (AMD64, Server) (push) Successful in 25m47s
Build / Build (ARM64, Client) (push) Successful in 30m50s
Build / Build (ARM64, Server) (push) Successful in 29m6s
Build / Build (ARMHF, Client) (push) Successful in 29m9s
Build / Build (ARMHF, Server) (push) Successful in 25m58s
Build / Release (push) Successful in 2m57s
Build / Test (push) Has been cancelled
40 lines
927 B
C
40 lines
927 B
C
#include <libreborn/libreborn.h>
|
|
|
|
#include "util.h"
|
|
|
|
// Simpler Version Of run_command()
|
|
void run_simple_command(const char *const command[], const char *error) {
|
|
int status = 0;
|
|
char *output = run_command(command, &status, NULL);
|
|
if (output != NULL) {
|
|
free(output);
|
|
}
|
|
if (!is_exit_status_success(status)) {
|
|
ERR("%s", error);
|
|
}
|
|
}
|
|
|
|
// Chop Off Last Component
|
|
void chop_last_component(char **str) {
|
|
size_t length = strlen(*str);
|
|
for (size_t i = 0; i < length; i++) {
|
|
size_t j = length - i - 1;
|
|
if ((*str)[j] == '/') {
|
|
(*str)[j] = '\0';
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
// Get Binary Directory (Remember To Free)
|
|
char *get_binary_directory() {
|
|
// Get Path To Current Executable
|
|
char *exe = realpath("/proc/self/exe", NULL);
|
|
ALLOC_CHECK(exe);
|
|
|
|
// Chop Off Last Component
|
|
chop_last_component(&exe);
|
|
|
|
// Return
|
|
return exe;
|
|
}
|