wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) { // get OS version int major, minor; wxString release = wxGetCommandOutput(wxT("uname -r")); if ( release.empty() || wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 ) { // failed to get version string or unrecognized format major = minor = -1; } if ( verMaj ) *verMaj = major; if ( verMin ) *verMin = minor; // try to understand which OS are we running wxString kernel = wxGetCommandOutput(wxT("uname -s")); if ( kernel.empty() ) kernel = wxGetCommandOutput(wxT("uname -o")); if ( kernel.empty() ) return wxOS_UNKNOWN; return wxPlatformInfo::GetOperatingSystemId(kernel); }
wxLinuxDistributionInfo wxGetLinuxDistributionInfo() { const wxString id = wxGetCommandOutput(wxT("lsb_release --id")); const wxString desc = wxGetCommandOutput(wxT("lsb_release --description")); const wxString rel = wxGetCommandOutput(wxT("lsb_release --release")); const wxString codename = wxGetCommandOutput(wxT("lsb_release --codename")); wxLinuxDistributionInfo ret; id.StartsWith("Distributor ID:\t", &ret.Id); desc.StartsWith("Description:\t", &ret.Description); rel.StartsWith("Release:\t", &ret.Release); codename.StartsWith("Codename:\t", &ret.CodeName); return ret; }
bool wxIsPlatform64Bit() { const wxString machine = wxGetCommandOutput(wxT("uname -m")); // the test for "64" is obviously not 100% reliable but seems to work fine // in practice return machine.Contains(wxT("64")) || machine.Contains(wxT("alpha")); }
static bool wxGetValueFromLSBRelease(wxString arg, const wxString& lhs, wxString* rhs) { // lsb_release seems to just read a global file which is always in UTF-8 // and hence its output is always in UTF-8 as well, regardless of the // locale currently configured by our environment. return wxGetCommandOutput(wxS("lsb_release ") + arg, wxConvUTF8) .StartsWith(lhs, rhs); }
wxString wxGetOsDescription() { return wxGetCommandOutput(wxT("uname -s -r -m")); }