diff options
author | Gleb Popov <6yearold@gmail.com> | 2020-10-22 19:33:41 +0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-10-23 02:09:17 +0200 |
commit | b883dd8a32b1b58910272ec4791aeb241914932e (patch) | |
tree | 02a3f5a3cbfd91da12ac62a54dab9cf1df679dbd /vcl | |
parent | dab751617f9cd483411a18a72a06edd6f6da2a6b (diff) |
Implement SalGenericInstance::getOSVersion() for FreeBSD.
Change-Id: I01f565bdfc3c46a94485a62cd0f249ce2002fe21
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104689
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/generic/app/geninst.cxx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/vcl/unx/generic/app/geninst.cxx b/vcl/unx/generic/app/geninst.cxx index b6611631b50d..c385ab57d587 100644 --- a/vcl/unx/generic/app/geninst.cxx +++ b/vcl/unx/generic/app/geninst.cxx @@ -22,6 +22,9 @@ #if defined(LINUX) # include <stdio.h> #endif +#if defined(__FreeBSD__) +# include <sys/utsname.h> +#endif #include <config_features.h> #if HAVE_FEATURE_OPENGL @@ -50,7 +53,6 @@ OUString SalGenericInstance::getOSVersion() { OUString aKernelVer = "unknown"; -// not so generic, but at least shared between all unix backend #if defined(LINUX) FILE* pVersion = fopen( "/proc/version", "r" ); if ( pVersion ) @@ -70,8 +72,26 @@ OUString SalGenericInstance::getOSVersion() } fclose( pVersion ); } -#endif return aKernelVer; +#elif defined(__FreeBSD__) + struct utsname stName; + if ( uname( &stName ) != 0 ) + return aKernelVer; + + sal_Int32 nDots = 0; + sal_Int32 nIndex = 0; + aKernelVer = OUString::createFromAscii( stName.release ); + while ( nIndex++ < aKernelVer.getLength() ) + { + const char c = stName.release[ nIndex ]; + if ( c == ' ' || c == '-' || ( c == '.' && nDots++ > 0 ) ) + break; + } + return OUString::createFromAscii( stName.sysname ) + " " + + aKernelVer.copy( 0, nIndex ); +#else + return aKernelVer; +#endif } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |