diff options
Diffstat (limited to 'louloulibs/utils')
-rw-r--r-- | louloulibs/utils/system.cpp | 21 | ||||
-rw-r--r-- | louloulibs/utils/system.hpp | 8 |
2 files changed, 29 insertions, 0 deletions
diff --git a/louloulibs/utils/system.cpp b/louloulibs/utils/system.cpp new file mode 100644 index 0000000..c0bee11 --- /dev/null +++ b/louloulibs/utils/system.cpp @@ -0,0 +1,21 @@ +#include <logger/logger.hpp> +#include <utils/system.hpp> +#include <sys/utsname.h> +#include <cstring> + +using namespace std::string_literals; + +namespace utils +{ +std::string get_system_name() +{ + struct utsname uts; + const int res = ::uname(&uts); + if (res == -1) + { + log_error("uname failed: ", std::strerror(errno)); + return "Unknown"; + } + return uts.sysname + " "s + uts.release; +} +}
\ No newline at end of file diff --git a/louloulibs/utils/system.hpp b/louloulibs/utils/system.hpp new file mode 100644 index 0000000..7ea1677 --- /dev/null +++ b/louloulibs/utils/system.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include <string> + +namespace utils +{ +std::string get_system_name(); +}
\ No newline at end of file |