| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/info/common/swinfokerneldatasource.h`/ |
| 2 | // Copyright 2021 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "common/fileutils.h"cxx . . $ `<file>/src/common/fileutils.h`/ |
| 7 | #include "core/idatasource.h"cxx . . $ `<file>/src/core/idatasource.h`/ |
| 8 | #include <spdlog/spdlog.h> |
| 9 | #include <string> |
| 10 | |
| 11 | class SWInfoKernelDataSourcecxx . . $ SWInfoKernelDataSource# : public IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::stringcxx . . $ std/string#> |
| 12 | { |
| 13 | public: |
| 14 | stdcxx . . $ std/::stringcxx . . $ std/string# sourcecxx . . $ SWInfoKernelDataSource#source(219584694fe2b248).() const override |
| 15 | { |
| 16 | return "/proc/version"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 17 | } |
| 18 | |
| 19 | bool readcxx . . $ SWInfoKernelDataSource#read(f38201682fc79d0a).(stdcxx . . $ std/::stringcxx . . $ std/string# &data) override |
| 20 | { |
| 21 | auto const lines = Utilscxx . . $ Utils/::Filecxx . . $ Utils/File/::readFileLinescxx . . $ Utils/File/readFileLines(951e54d16e2206f).(sourcecxx . . $ SWInfoKernelDataSource#source(219584694fe2b248).()); |
| 22 | if (!lines.emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 23 | data =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). lines.frontcxx . . $ std/vector#front(af0004c3ce7cab93).(); |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | SPDLOG_WARNcxx . . $ fmt/v10/basic_string_view#basic_string_view(88376428bb603c08).("Cannot retrieve kernel version"); |
| 28 | return false; |
| 29 | } |
| 30 | }; |