libcruft-util/exe_freebsd.cpp
Danny Robson f6056153e3 rename root namespace from util to cruft
This places, at long last, the core library code into the same namespace
as the extended library code.
2018-08-05 14:42:02 +10:00

26 lines
512 B
C++

#include "types.hpp"
#include "except.hpp"
#include <sys/types.h>
#include <sys/sysctl.h>
std::experimental::filesystem::path
cruft::image_path (void)
{
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);
}