MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / getOSString

Function getOSString

src/date/buildDate.cpp:164–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164std::string getOSString() {
165 std::string versionString = "unknown";
166#ifdef _WIN32
167 // build up version string
168 OSVERSIONINFOEX versionInfo;
169 SYSTEM_INFO systemInfo;
170
171 versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
172 GetVersionEx((LPOSVERSIONINFO)&versionInfo);
173 GetNativeSystemInfo(&systemInfo);
174
175 std::string platform = "Win32";
176 if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
177 platform = "Win64";
178 }
179 if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
180 platform = "WinIA64";
181 }
182 versionString = TextUtils::format("%s %d.%d.%d sp%d.%d", platform.c_str(), versionInfo.dwMajorVersion, versionInfo.dwMinorVersion, versionInfo.dwBuildNumber, versionInfo.wServicePackMajor, versionInfo.wServicePackMinor);
183#else
184#ifdef __APPLE__
185 OSErr err = noErr;
186
187 SInt32 systemMajor, systemMinor, systemBugFix = 0;
188 err = Gestalt(gestaltSystemVersionMajor, &systemMajor);
189 if (err == noErr) {
190 err = Gestalt(gestaltSystemVersionMinor, &systemMinor);
191 if (err == noErr) {
192 err = Gestalt(gestaltSystemVersionBugFix, &systemBugFix);
193 }
194 }
195
196 std::stringstream reply;
197 if (err == noErr) {
198 reply << "Mac OS X ";
199 reply << systemMajor;
200 reply << ".";
201 reply << systemMinor;
202 reply << ".";
203 reply << systemBugFix;
204 }
205 else {
206 reply << "unknown system version (Gestalt error)";
207 }
208
209 // determine hardware platform at runtime because
210 // application may run using binary for different platform
211 size_t length;
212 sysctlbyname("hw.machine", NULL, &length, NULL, 0);
213
214 char* architecture = (char*) malloc(length);
215 if (sysctlbyname("hw.machine", architecture, &length, NULL, 0) == 0) {
216 reply << " " << architecture;
217 }
218 else {
219 reply << " unknown architecture";
220 }
221 free(architecture);

Callers 3

handleQueryOSFunction · 0.85
startPlayingFunction · 0.85
GetVersionMethod · 0.85

Calls 5

c_strMethod · 0.80
strMethod · 0.80
formatFunction · 0.50
tokenizeFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected