2016-10-10 16:23:07 +11:00
|
|
|
|
|
|
|
#include "types.hpp"
|
|
|
|
#include "except.hpp"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
std::experimental::filesystem::path
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::image_path (void)
|
2016-10-10 16:23:07 +11:00
|
|
|
{
|
|
|
|
int name[] = {
|
|
|
|
CTL_KERN,
|
|
|
|
KERN_PROC,
|
|
|
|
KERN_PROC_PATHNAME,
|
|
|
|
-1
|
|
|
|
};
|
|
|
|
|
|
|
|
char data[1024];
|
|
|
|
size_t len = sizeof (data);
|
|
|
|
|
|
|
|
auto err = sysctl (name, elems (name), data, &len, nullptr, 0);
|
|
|
|
errno_error::try_code (err);
|
|
|
|
|
|
|
|
return std::experimental::filesystem::path (std::cbegin (data), std::cbegin (data) + len);
|
|
|
|
}
|