MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / GetAppleVersion

Function GetAppleVersion

Sources/Shared/Environment.cpp:72–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71#if defined(DEATH_TARGET_APPLE)
72 Containers::String GetAppleVersion()
73 {
74 FILE* fp = ::fopen("/System/Library/CoreServices/SystemVersion.plist", "r");
75 if (fp == nullptr) {
76 return {};
77 }
78
79 Containers::String result;
80
81 // Look for the line containing the macOS version information
82 char line[128];
83 while (::fgets(line, sizeof(line), fp) != nullptr) {
84 if (strstr(line, "<key>ProductVersion</key>") != nullptr) {
85 break;
86 }
87 }
88
89 // Read the macOS version from the corresponding value tag
90 if (::fgets(line, sizeof(line), fp) != nullptr) {
91 char* versionStart = strchr(line, '>');
92 if (versionStart != nullptr) {
93 char* versionEnd = strchr(versionStart, '<');
94 if (versionEnd != nullptr) {
95 result = Containers::String(versionStart + 1, versionEnd - versionStart - 1);
96 }
97 }
98 }
99
100 ::fclose(fp);
101
102 return result;
103 }
104#endif
105
106#if defined(DEATH_TARGET_SWITCH)

Callers 1

GetDeviceIDMethod · 0.85

Calls 1

StringClass · 0.50

Tested by

no test coverage detected