15 #define GETTEXT_DOMAIN "wesnoth-lib"
28 #if defined(_X11) || defined(__APPLE__)
31 #include <sys/utsname.h>
40 #define WIN32_LEAN_AND_MEAN
47 #define ERR_DU LOG_STREAM(err, log_desktop)
48 #define LOG_DU LOG_STREAM(info, log_desktop)
65 HMODULE ntdll = GetModuleHandle(L
"ntdll.dll");
70 return GetProcAddress(ntdll,
"wine_get_version") !=
nullptr;
74 #if defined(_X11) || defined(__APPLE__)
78 struct posix_pipe_release_policy
80 void operator()(std::FILE*
f)
const {
if(f !=
nullptr) { pclose(f); } }
108 while((c = std::fgetc(p)) && c != EOF && c !=
'\n' && c !=
'\r') {
109 ver.push_back(static_cast<char>(c));
120 #if defined(_X11) || defined(__APPLE__)
128 static const std::string version_plist =
"/System/Library/CoreServices/SystemVersion.plist";
129 static const std::string defaults_bin =
"/usr/bin/defaults";
133 = defaults_bin +
" read " + version_plist +
" ProductUserVisibleVersion";
135 scoped_posix_pipe
p(popen(cmdline.c_str(),
"r"));
139 return "Apple OS X " + ver;
149 static const std::string lsb_release_bin =
"/usr/bin/lsb_release";
152 static const std::string cmdline = lsb_release_bin +
" -s -d";
154 scoped_posix_pipe
p(popen(cmdline.c_str(),
"r"));
157 if(ver.length() >= 2 && ver[0] ==
'"' && ver[ver.length() - 1] ==
'"') {
158 ver.erase(ver.length() - 1, 1);
176 ERR_DU <<
"os_version: uname error (" << strerror(errno) <<
")\n";
184 #elif defined(_WIN32)
191 = !on_wine() ?
"Microsoft Windows" :
"Wine/Microsoft Windows";
193 OSVERSIONINFOEX
v = {
sizeof(OSVERSIONINFOEX) };
195 if(!GetVersionEx(reinterpret_cast<OSVERSIONINFO*>(&v))) {
196 ERR_DU <<
"os_version: GetVersionEx error ("
197 << GetLastError() <<
")\n";
201 const DWORD vnum = v.dwMajorVersion * 100 + v.dwMinorVersion;
214 version =
"Server 2003";
217 if(v.wProductType == VER_NT_WORKSTATION) {
220 version =
"Server 2008";
224 if(v.wProductType == VER_NT_WORKSTATION) {
227 version =
"Server 2008 R2";
231 if(v.wProductType == VER_NT_WORKSTATION) {
234 version =
"Server 2012";
238 if(v.wProductType == VER_NT_WORKSTATION) {
241 version =
"Server 2012 R2";
245 if(v.wProductType == VER_NT_WORKSTATION) {
250 if(v.wProductType != VER_NT_WORKSTATION) {
255 if(v.szCSDVersion && *v.szCSDVersion) {
263 << v.dwMajorVersion <<
'.'
264 << v.dwMinorVersion <<
'.'
265 << v.dwBuildNumber).str();
276 ERR_DU <<
"os_version(): unsupported platform\n";
277 return _(
"operating_system^<unknown>");
static lg::log_domain log_desktop("desktop")
ucs4_convert_impl::enableif< TD, typename TS::value_type >::type unicode_cast(const TS &source)
scoped_resource: class template, functions, helper policies etc. for resource management.
static UNUSEDNOWARN std::string _(const char *str)
A class template, scoped_resource, designed to implement the Resource Acquisition Is Initialization (...
Platform identification and version information functions.
std::string os_version()
Returns a string with the running OS name and version information.
Declarations for File-IO.
Standard logging facilities (interface).
bool file_exists(const std::string &name)
Returns true if a file or directory with such name already exists.
const std::string version
GLsizei const GLcharARB ** string