Index: src/OFSystemInfo.h ================================================================== --- src/OFSystemInfo.h +++ src/OFSystemInfo.h @@ -27,12 +27,14 @@ */ @interface OFSystemInfo: OFObject #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic) size_t pageSize; @property (class, readonly, nonatomic) size_t numberOfCPUs; +# 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; # if defined(OF_X86_64) || defined(OF_X86) || defined(DOXYGEN) @property (class, readonly, nonatomic) bool supportsMMX; @property (class, readonly, nonatomic) bool supportsSSE; @property (class, readonly, nonatomic) bool supportsSSE2; @@ -62,10 +64,11 @@ * * @return The number of CPUs installed in the system */ + (size_t)numberOfCPUs; +#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 * On Mac OS X and iOS, it uses the `NSApplicationSupportDirectory` directory.@n @@ -87,10 +90,11 @@ * On Haiku, it uses the `B_USER_SETTINGS_DIRECTORY` directory. * * @return The path where user configuration for the application can be stored */ + (nullable OFString *)userConfigPath; +#endif /*! * @brief Returns the vendor of the CPU. * * If the vendor could not be determined, `nil` is returned instead. Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -169,17 +169,18 @@ + (size_t)numberOfCPUs { return numberOfCPUs; } +#ifdef OF_HAVE_FILES + (OFString *)userDataPath { -#if defined(OF_MACOS) || defined(OF_IOS) +# if defined(OF_MACOS) || defined(OF_IOS) char pathC[PATH_MAX]; OFMutableString *path; -# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION +# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION /* (1) to disable dead code warning when it is not a weak symbol */ if ((1) && &sysdir_start_search_path_enumeration != NULL) { sysdir_search_path_enumeration_state state; state = sysdir_start_search_path_enumeration( @@ -188,22 +189,22 @@ if (sysdir_get_next_search_path_enumeration(state, pathC) == 0) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; } else { -# endif +# endif NSSearchPathEnumerationState state; state = NSStartSearchPathEnumeration( NSApplicationSupportDirectory, NSUserDomainMask); if (NSGetNextSearchPathEnumeration(state, pathC) == 0) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; -# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION +# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION } -# endif +# endif path = [OFMutableString stringWithUTF8String: pathC]; if ([path hasPrefix: @"~"]) { OFDictionary *env = [OFApplication environment]; OFString *home; @@ -218,29 +219,29 @@ } [path makeImmutable]; return path; -#elif defined(OF_WINDOWS) +# elif defined(OF_WINDOWS) OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; return appData; -#elif defined(OF_HAIKU) +# elif defined(OF_HAIKU) char pathC[PATH_MAX]; if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, pathC, PATH_MAX) != B_OK) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; return [OFString stringWithUTF8String: pathC]; -#else +# else OFDictionary *env = [OFApplication environment]; OFString *var; void *pool; if ((var = [env objectForKey: @"XDG_DATA_HOME"]) != nil && @@ -257,20 +258,20 @@ var, @".local", @"share", nil]] retain]; objc_autoreleasePoolPop(pool); return [var autorelease]; -#endif +# endif } + (OFString *)userConfigPath { -#if defined(OF_MACOS) || defined(OF_IOS) +# if defined(OF_MACOS) || defined(OF_IOS) char pathC[PATH_MAX]; OFMutableString *path; -# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION +# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION /* (1) to disable dead code warning when it is not a weak symbol */ if ((1) && &sysdir_start_search_path_enumeration != NULL) { sysdir_search_path_enumeration_state state; state = sysdir_start_search_path_enumeration( @@ -278,22 +279,22 @@ if (sysdir_get_next_search_path_enumeration(state, pathC) == 0) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; } else { -# endif +# endif NSSearchPathEnumerationState state; state = NSStartSearchPathEnumeration(NSLibraryDirectory, NSUserDomainMask); if (NSGetNextSearchPathEnumeration(state, pathC) == 0) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; -# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION +# ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION } -# endif +# endif path = [OFMutableString stringWithUTF8String: pathC]; if ([path hasPrefix: @"~"]) { OFDictionary *env = [OFApplication environment]; OFString *home; @@ -310,29 +311,29 @@ [path appendString: @"/Preferences"]; [path makeImmutable]; return path; -#elif defined(OF_WINDOWS) +# elif defined(OF_WINDOWS) OFDictionary *env = [OFApplication environment]; OFString *appData; if ((appData = [env objectForKey: @"APPDATA"]) == nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; return appData; -#elif defined(OF_HAIKU) +# elif defined(OF_HAIKU) char pathC[PATH_MAX]; if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, pathC, PATH_MAX) != B_OK) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; return [OFString stringWithUTF8String: pathC]; -#else +# else OFDictionary *env = [OFApplication environment]; OFString *var; if ((var = [env objectForKey: @"XDG_CONFIG_HOME"]) != nil && [var length] > 0) @@ -341,12 +342,13 @@ if ((var = [env objectForKey: @"HOME"]) == nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; return [var stringByAppendingPathComponent: @".config"]; -#endif +# endif } +#endif + (OFString *)CPUVendor { #if defined(OF_X86_64_ASM) || defined(OF_X86_ASM) struct x86_regs regs = x86_cpuid(0, 0);