Overview
Comment: | Implement +[operatingSystemVersion] for macOS/iOS |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
01104c5e8588ca7c555aa1092f6dddf8 |
User & Date: | js on 2018-03-18 00:52:27 |
Other Links: | manifest | tags |
Context
2018-03-18
| ||
01:01 | socket.m: Minor cleanup check-in: 885d84a1a7 user: js tags: trunk | |
00:52 | Implement +[operatingSystemVersion] for macOS/iOS check-in: 01104c5e85 user: js tags: trunk | |
00:28 | Add support for parsing XML property lists check-in: db0bf9d5a7 user: js tags: trunk | |
Changes
Modified src/OFSystemInfo.m from [b1d4d96275] to [d2ab194f29].
︙ | ︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #import "OFApplication.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFLocalization.h" #import "OFString.h" #import "OFNotImplementedException.h" #if defined(OF_MACOS) || defined(OF_IOS) # ifdef HAVE_SYSDIR_H # include <sysdir.h> # endif #endif #ifdef OF_WINDOWS | > > > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #import "OFApplication.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFLocalization.h" #import "OFString.h" #import "OFNotImplementedException.h" #ifdef OF_HAVE_THREADS # import "threading.h" #endif #if defined(OF_MACOS) || defined(OF_IOS) # ifdef HAVE_SYSDIR_H # include <sysdir.h> # endif #endif #ifdef OF_WINDOWS |
︙ | ︙ | |||
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | struct x86_regs { uint32_t eax, ebx, ecx, edx; }; #endif static size_t pageSize; static size_t numberOfCPUs; #if defined(OF_X86_64) || defined(OF_X86) static OF_INLINE struct x86_regs OF_CONST_FUNC x86_cpuid(uint32_t eax, uint32_t ecx) { struct x86_regs regs; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | struct x86_regs { uint32_t eax, ebx, ecx, edx; }; #endif static size_t pageSize; static size_t numberOfCPUs; static OFString *operatingSystemName = nil; static OFString *operatingSystemVersion = nil; static void initOperatingSystemName(void) { #if defined(OF_IOS) operatingSystemName = @"iOS"; #elif defined(OF_MACOS) operatingSystemName = @"macOS"; #elif defined(OF_WINDOWS) operatingSystemName = @"Windows"; #elif defined(OF_ANDROID) operatingSystemName = @"Android"; #elif defined(OF_MORPHOS) operatingSystemName = @"MorphOS"; #elif defined(OF_AMIGAOS4) operatingSystemName = @"AmigaOS 4"; #elif defined(OF_WII) operatingSystemName = @"Nintendo Wii"; #elif defined(NINTENDO_3DS) operatingSystemName = @"Nintendo 3DS"; #elif defined(OF_NINTENDO_DS) operatingSystemName = @"Nintendo DS"; #elif defined(OF_PSP) operatingSystemName = @"PlayStation Portable"; #elif defined(OF_MSDOS) operatingSystemName = @"MS-DOS"; #elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) struct utsname utsname; if (uname(&utsname) != 0) return; operatingSystemName = [[OFString alloc] initWithCString: utsname.sysname encoding: [OFLocalization encoding]]; #endif } static void initOperatingSystemVersion(void) { #if defined(OF_IOS) || defined(OF_MACOS) void *pool = objc_autoreleasePoolPush(); @try { OFString *propertyList = [OFString stringWithContentsOfFile: @"/System/Library/CoreServices/SystemVersion.plist"]; operatingSystemVersion = [[[propertyList propertyListValue] objectForKey: @"ProductVersion"] copy]; } @finally { objc_autoreleasePoolPop(pool); } #elif defined(OF_WINDOWS) /* TODO */ #elif defined(OF_ANDROID) /* TODO */ #elif defined(OF_MORPHOS) /* TODO */ #elif defined(OF_AMIGAOS4) /* TODO */ #elif defined(OF_WII) || defined(NINTENDO_3DS) || defined(OF_NINTENDO_DS) || \ defined(OF_PSP) || defined(OF_MSDOS) #elif defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) struct utsname u; if (uname(&utsname) != 0) return nil; operatingSystemVersion = [[OFString alloc] initWithCString: utsname.release encoding: [OFLocalization encoding]]; #endif } #if defined(OF_X86_64) || defined(OF_X86) static OF_INLINE struct x86_regs OF_CONST_FUNC x86_cpuid(uint32_t eax, uint32_t ecx) { struct x86_regs regs; |
︙ | ︙ | |||
173 174 175 176 177 178 179 | + (size_t)numberOfCPUs { return numberOfCPUs; } + (OFString *)operatingSystemName { | | | | < < < < < < < < < | < < < < < < | | < < > | | | < < < < | < | | | | < | | < | < < < < < < < < < < | | | < < < < | < | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | + (size_t)numberOfCPUs { return numberOfCPUs; } + (OFString *)operatingSystemName { #ifdef OF_HAVE_THREADS static of_once_t onceControl = OF_ONCE_INIT; of_once(&onceControl, initOperatingSystemName); #else static bool initialized = false; if (!initialized) { initOperatingSystemName(); initialized = true; } #endif return operatingSystemName; } + (OFString *)operatingSystemVersion { #ifdef OF_HAVE_THREADS static of_once_t onceControl = OF_ONCE_INIT; of_once(&onceControl, initOperatingSystemVersion); #else static bool initialized = false; if (!initialized) { initOperatingSystemVersion(); initialized = true; } #endif return operatingSystemVersion; } #ifdef OF_HAVE_FILES + (OFString *)userDataPath { # if defined(OF_MACOS) || defined(OF_IOS) char pathC[PATH_MAX]; |
︙ | ︙ |