Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -44,12 +44,10 @@ #import "OFNotImplementedException.h" #if defined(OF_MACOS) || defined(OF_IOS) # ifdef HAVE_SYSDIR_H # include -# else -# include # endif #endif #ifdef OF_WINDOWS # include #endif @@ -57,10 +55,36 @@ # include #endif #ifdef OF_QNX # include #endif + +#if defined(OF_MACOS) || defined(OF_IOS) +/* + * These have been dropped from newer iOS SDKs, however, their replacements are + * not available on iOS < 10. This means it's impossible to search for the + * paths when using a new SDK while targeting iOS 9 or earlier. To work around + * this, we define those manually, only to be used when the replacements are + * not available at runtime. + */ + +typedef enum { + NSLibraryDirectory = 5, + NSApplicationSupportDirectory = 14 +} NSSearchPathDirectory; + +typedef enum { + NSUserDomainMask = 1 +} NSSearchPathDomainMask; + +typedef unsigned int NSSearchPathEnumerationState; + +extern NSSearchPathEnumerationState NSStartSearchPathEnumeration( + NSSearchPathDirectory, NSSearchPathDomainMask); +extern NSSearchPathEnumerationState NSGetNextSearchPathEnumeration( + NSSearchPathEnumerationState, char *); +#endif #if defined(OF_X86_64) || defined(OF_X86) struct x86_regs { uint32_t eax, ebx, ecx, edx; }; @@ -151,25 +175,33 @@ #if defined(OF_MACOS) || defined(OF_IOS) char pathC[PATH_MAX]; OFMutableString *path; # ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION - sysdir_search_path_enumeration_state state; - - state = sysdir_start_search_path_enumeration( - SYSDIR_DIRECTORY_APPLICATION_SUPPORT, SYSDIR_DOMAIN_MASK_USER); - if (sysdir_get_next_search_path_enumeration(state, pathC) == 0) - @throw [OFNotImplementedException exceptionWithSelector: _cmd - object: self]; -# else - NSSearchPathEnumerationState state; - - state = NSStartSearchPathEnumeration(NSApplicationSupportDirectory, - NSUserDomainMask); - if (NSGetNextSearchPathEnumeration(state, pathC) == 0) - @throw [OFNotImplementedException exceptionWithSelector: _cmd - object: self]; + /* (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( + SYSDIR_DIRECTORY_APPLICATION_SUPPORT, + SYSDIR_DOMAIN_MASK_USER); + if (sysdir_get_next_search_path_enumeration(state, pathC) == 0) + @throw [OFNotImplementedException + exceptionWithSelector: _cmd + object: self]; + } else { +# 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 + } # endif path = [OFMutableString stringWithUTF8String: pathC]; if ([path hasPrefix: @"~"]) { OFDictionary *env = [OFApplication environment]; @@ -234,25 +266,32 @@ #if defined(OF_MACOS) || defined(OF_IOS) char pathC[PATH_MAX]; OFMutableString *path; # ifdef HAVE_SYSDIR_START_SEARCH_PATH_ENUMERATION - sysdir_search_path_enumeration_state state; - - state = sysdir_start_search_path_enumeration( - SYSDIR_DIRECTORY_LIBRARY, SYSDIR_DOMAIN_MASK_USER); - if (sysdir_get_next_search_path_enumeration(state, pathC) == 0) - @throw [OFNotImplementedException exceptionWithSelector: _cmd - object: self]; -# else - NSSearchPathEnumerationState state; - - state = NSStartSearchPathEnumeration(NSLibraryDirectory, - NSUserDomainMask); - if (NSGetNextSearchPathEnumeration(state, pathC) == 0) - @throw [OFNotImplementedException exceptionWithSelector: _cmd - object: self]; + /* (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( + SYSDIR_DIRECTORY_LIBRARY, SYSDIR_DOMAIN_MASK_USER); + if (sysdir_get_next_search_path_enumeration(state, pathC) == 0) + @throw [OFNotImplementedException + exceptionWithSelector: _cmd + object: self]; + } else { +# 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 + } # endif path = [OFMutableString stringWithUTF8String: pathC]; if ([path hasPrefix: @"~"]) { OFDictionary *env = [OFApplication environment];