blob: 040173a2e58af22103ee2717ecc7b1ea20ed60ff (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/platform/OSVersionInfo.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/StringUtils.h>
#include <sys/utsname.h>
namespace Aws
{
namespace OSVersionInfo
{
Aws::String GetSysCommandOutput(const char* command)
{
Aws::String outputStr;
FILE* outputStream;
const int maxBufferSize = 256;
char outputBuffer[maxBufferSize];
outputStream = popen(command, "r");
if (outputStream)
{
while (!feof(outputStream))
{
if (fgets(outputBuffer, maxBufferSize, outputStream) != nullptr)
{
outputStr.append(outputBuffer);
}
}
pclose(outputStream);
return Aws::Utils::StringUtils::Trim(outputStr.c_str());
}
return {};
}
Aws::String ComputeOSVersionString()
{
utsname name;
int32_t success = uname(&name);
if(success >= 0)
{
Aws::StringStream ss;
ss << name.sysname << "/" << name.release << " " << name.machine;
return ss.str();
}
return "non-windows/unknown";
}
} // namespace OSVersionInfo
} // namespace Aws
|