summaryrefslogtreecommitdiff
path: root/louloulibs/utils
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-02-27 18:01:20 +0100
committerlouiz’ <louiz@louiz.org>2017-02-27 18:01:20 +0100
commitd81cbc4a33ee2c28628ccb632af9ae1b27e84d03 (patch)
treee301669f22080be2241e082af34c6d8c8979f5ec /louloulibs/utils
parent9f978cda943619c95a41e5da9047c3cc0dd31555 (diff)
downloadbiboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.tar.gz
biboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.tar.bz2
biboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.tar.xz
biboumi-d81cbc4a33ee2c28628ccb632af9ae1b27e84d03.zip
Use uname() instead of CMAKE_SYSTEM
fix #3235
Diffstat (limited to 'louloulibs/utils')
-rw-r--r--louloulibs/utils/system.cpp21
-rw-r--r--louloulibs/utils/system.hpp8
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