Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1059,10 +1059,13 @@ AC_CHECK_HEADERS(fcntl.h dirent.h) AC_CHECK_FUNCS([sysconf gmtime_r localtime_r nanosleep fcntl]) AC_CHECK_HEADERS(xlocale.h) AC_CHECK_FUNCS([strtod_l strtof_l asprintf_l]) + +AC_CHECK_HEADERS(sys/utsname.h) +AC_CHECK_FUNCS(uname) AC_CHECK_FUNC(pipe, [ AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()]) ]) Index: src/OFSystemInfo.h ================================================================== --- src/OFSystemInfo.h +++ src/OFSystemInfo.h @@ -27,10 +27,13 @@ */ @interface OFSystemInfo: OFObject #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) size_t pageSize; @property (class, readonly, nonatomic) size_t numberOfCPUs; +@property (class, readonly, nullable, nonatomic) OFString *operatingSystemName; +@property (class, readonly, nullable, nonatomic) + OFString *operatingSystemVersion; # ifdef OF_HAVE_FILES @property (class, readonly, nullable, nonatomic) OFString *userDataPath; @property (class, readonly, nullable, nonatomic) OFString *userConfigPath; # endif @property (class, readonly, nullable, nonatomic) OFString *CPUVendor; @@ -64,10 +67,26 @@ * * @return The number of CPUs installed in the system */ + (size_t)numberOfCPUs; +/** + * @brief Returns the name of the operating system the application is running + * on. + * + * @return The name of the operating system the application is running on + */ ++ (nullable OFString *)operatingSystemName; + +/** + * @brief Returns the version of the operating system the application is + * running on. + * + * @return The version of the operating system the application is running on + */ ++ (nullable OFString *)operatingSystemVersion; + #ifdef OF_HAVE_FILES /*! * @brief Returns the path where user data for the application can be stored. * * On Unix systems, this adheres to the XDG Base Directory specification.@n Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -23,10 +23,13 @@ #include "unistd_wrapper.h" #include "platform.h" +#ifdef HAVE_SYS_UTSNAME_H +# include +#endif #ifdef OF_MACOS # include #endif #ifdef OF_MORPHOS @@ -35,14 +38,15 @@ # include # undef BOOL #endif #import "OFSystemInfo.h" -#import "OFString.h" +#import "OFApplication.h" #import "OFArray.h" #import "OFDictionary.h" -#import "OFApplication.h" +#import "OFLocalization.h" +#import "OFString.h" #import "OFNotImplementedException.h" #if defined(OF_MACOS) || defined(OF_IOS) # ifdef HAVE_SYSDIR_H @@ -168,10 +172,80 @@ + (size_t)numberOfCPUs { return numberOfCPUs; } + ++ (OFString *)operatingSystemName +{ +#if defined(OF_IOS) + return @"iOS"; +#elif defined(OF_MACOS) + return @"macOS"; +#elif defined(OF_WINDOWS) + return @"Windows"; +#elif defined(OF_ANDROID) + return @"Android"; +#elif defined(OF_MORPHOS) + return @"MorphOS"; +#elif defined(OF_AMIGAOS4) + return @"AmigaOS 4"; +#elif defined(OF_WII) + return @"Nintendo Wii"; +#elif defined(NINTENDO_3DS) + return @"Nintendo 3DS"; +#elif defined(OF_NINTENDO_DS) + return @"Nintendo DS"; +#elif defined(OF_PSP) + return @"PlayStation Portable"; +#elif defined(OF_MSDOS) + return @"MS-DOS"; +#elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) + struct utsname u; + + if (uname(&u) != 0) + return nil; + + return [OFString stringWithCString: u.sysname + encoding: [OFLocalization encoding]]; +#else + return nil; +#endif +} + ++ (OFString *)operatingSystemVersion +{ +#if defined(OF_IOS) || defined(OF_MACOS) + /* TODO */ + return nil; +#elif defined(OF_WINDOWS) + /* TODO */ + return nil; +#elif defined(OF_ANDROID) + /* TODO */ + return nil; +#elif defined(OF_MORPHOS) + /* TODO */ + return nil; +#elif defined(OF_AMIGAOS4) + /* TODO */ + return nil; +#elif defined(OF_WII) || defined(NINTENDO_3DS) || defined(OF_NINTENDO_DS) || \\ + defined(OF_PSP) || defined(OF_MSDOS) + return nil; +#elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) + struct utsname u; + + if (uname(&u) != 0) + return nil; + + return [OFString stringWithCString: u.release + encoding: [OFLocalization encoding]]; +#else + return nil; +#endif +} #ifdef OF_HAVE_FILES + (OFString *)userDataPath { # if defined(OF_MACOS) || defined(OF_IOS)