mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-01 01:03:11 +00:00
Move code around - turn platform_apple.c into platform_apple.m
This commit is contained in:
parent
6beaa824cd
commit
a554b1647c
@ -16,10 +16,13 @@
|
||||
*/
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreFoundation/CFArray.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include "../../ui/drivers/cocoa/CFExtensions.h"
|
||||
#ifdef __OBJC__
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
#endif
|
||||
|
||||
#include "../frontend_driver.h"
|
||||
#include "../../ui/ui_companion_driver.h"
|
||||
@ -36,8 +39,122 @@
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <IOKit/ps/IOPowerSources.h>
|
||||
#include <IOKit/ps/IOPSKeys.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CFApplicationDirectory = 1, // supported applications (Applications)
|
||||
CFDemoApplicationDirectory, // unsupported applications, demonstration versions (Demos)
|
||||
CFDeveloperApplicationDirectory, // developer applications (Developer/Applications). DEPRECATED - there is no one single Developer directory.
|
||||
CFAdminApplicationDirectory, // system and network administration applications (Administration)
|
||||
CFLibraryDirectory, // various documentation, support, and configuration files, resources (Library)
|
||||
CFDeveloperDirectory, // developer resources (Developer) DEPRECATED - there is no one single Developer directory.
|
||||
CFUserDirectory, // user home directories (Users)
|
||||
CFDocumentationDirectory, // documentation (Documentation)
|
||||
CFDocumentDirectory, // documents (Documents)
|
||||
CFCoreServiceDirectory, // location of CoreServices directory (System/Library/CoreServices)
|
||||
CFAutosavedInformationDirectory = 11, // location of autosaved documents (Documents/Autosaved)
|
||||
CFDesktopDirectory = 12, // location of user's desktop
|
||||
CFCachesDirectory = 13, // location of discardable cache files (Library/Caches)
|
||||
CFApplicationSupportDirectory = 14, // location of application support files (plug-ins, etc) (Library/Application Support)
|
||||
CFDownloadsDirectory = 15, // location of the user's "Downloads" directory
|
||||
CFInputMethodsDirectory = 16, // input methods (Library/Input Methods)
|
||||
CFMoviesDirectory = 17, // location of user's Movies directory (~/Movies)
|
||||
CFMusicDirectory = 18, // location of user's Music directory (~/Music)
|
||||
CFPicturesDirectory = 19, // location of user's Pictures directory (~/Pictures)
|
||||
CFPrinterDescriptionDirectory = 20, // location of system's PPDs directory (Library/Printers/PPDs)
|
||||
CFSharedPublicDirectory = 21, // location of user's Public sharing directory (~/Public)
|
||||
CFPreferencePanesDirectory = 22, // location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes)
|
||||
CFApplicationScriptsDirectory = 23, // location of the user scripts folder for the calling application (~/Library/Application Scripts/code-signing-id)
|
||||
CFItemReplacementDirectory = 99, // For use with NSFileManager's URLForDirectory:inDomain:appropriateForURL:create:error:
|
||||
CFAllApplicationsDirectory = 100, // all directories where applications can occur
|
||||
CFAllLibrariesDirectory = 101, // all directories where resources can occur
|
||||
CFTrashDirectory = 102 // location of Trash directory
|
||||
} CFSearchPathDirectory;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CFUserDomainMask = 1, // user's home directory --- place to install user's personal items (~)
|
||||
CFLocalDomainMask = 2, // local to the current machine --- place to install items available to everyone on this machine (/Library)
|
||||
CFNetworkDomainMask = 4, // publically available location in the local area network --- place to install items available on the network (/Network)
|
||||
CFSystemDomainMask = 8, // provided by Apple, unmodifiable (/System)
|
||||
CFAllDomainsMask = 0x0ffff // all domains: all of the above and future items
|
||||
} CFDomainMask;
|
||||
|
||||
#ifndef __has_feature
|
||||
/* Compatibility with non-Clang compilers. */
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
|
||||
#ifndef CF_RETURNS_RETAINED
|
||||
#if __has_feature(attribute_cf_returns_retained)
|
||||
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
|
||||
#else
|
||||
#define CF_RETURNS_RETAINED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X)
|
||||
{
|
||||
#if __has_feature(objc_arc)
|
||||
return (__bridge_retained CFTypeRef)X;
|
||||
#else
|
||||
return X;
|
||||
#endif
|
||||
}
|
||||
|
||||
static NSSearchPathDirectory NSConvertFlagsCF(unsigned flags)
|
||||
{
|
||||
switch (flags)
|
||||
{
|
||||
case CFDocumentDirectory:
|
||||
return NSDocumentDirectory;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NSSearchPathDomainMask NSConvertDomainFlagsCF(unsigned flags)
|
||||
{
|
||||
switch (flags)
|
||||
{
|
||||
case CFUserDomainMask:
|
||||
return NSUserDomainMask;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CFSearchPathForDirectoriesInDomains(unsigned flags,
|
||||
unsigned domain_mask, unsigned expand_tilde,
|
||||
char *buf, size_t sizeof_buf)
|
||||
{
|
||||
CFTypeRef array_val = (CFTypeRef)CFBridgingRetainCompat(
|
||||
NSSearchPathForDirectoriesInDomains(NSConvertFlagsCF(flags),
|
||||
NSConvertDomainFlagsCF(domain_mask), (BOOL)expand_tilde));
|
||||
CFArrayRef array = array_val ? CFRetain(array_val) : NULL;
|
||||
CFTypeRef path_val = (CFTypeRef)CFArrayGetValueAtIndex(array, 0);
|
||||
CFStringRef path = path_val ? CFRetain(path_val) : NULL;
|
||||
if (!path || !array)
|
||||
return;
|
||||
|
||||
CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8);
|
||||
CFRelease(path);
|
||||
CFRelease(array);
|
||||
}
|
||||
|
||||
void CFTemporaryDirectory(char *buf, size_t sizeof_buf)
|
||||
{
|
||||
#if __has_feature(objc_arc)
|
||||
CFStringRef path = (__bridge_retained CFStringRef)NSTemporaryDirectory();
|
||||
#else
|
||||
CFStringRef path = (CFStringRef)NSTemporaryDirectory();
|
||||
#endif
|
||||
CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8);
|
||||
}
|
||||
|
||||
#if defined(IOS)
|
||||
void get_ios_version(int *major, int *minor);
|
||||
|
@ -609,8 +609,6 @@ FRONTEND
|
||||
#include "../frontend/drivers/platform_ctr.c"
|
||||
#elif defined(__QNX__)
|
||||
#include "../frontend/drivers/platform_qnx.c"
|
||||
#elif defined(__APPLE__)
|
||||
#include "../frontend/drivers/platform_apple.c"
|
||||
#elif defined(ANDROID)
|
||||
#include "../frontend/drivers/platform_android.c"
|
||||
#elif defined(__linux__) && !defined(ANDROID)
|
||||
|
@ -23,6 +23,10 @@
|
||||
#define __IPHONE_OS_VERSION_MAX_ALLOWED 00000
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include "../frontend/drivers/platform_apple.m"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA)
|
||||
#include "../gfx/drivers_context/apple_cocoa_gl.m"
|
||||
#include "../ui/drivers/cocoa/cocoa_common.m"
|
||||
|
@ -1,68 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2013-2014 - Jason Fetters
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __COREFOUNDATION_TO_NSFOUNDATION_EXTENSIONS_H
|
||||
#define __COREFOUNDATION_TO_NSFOUNDATION_EXTENSIONS_H
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreFoundation/CFArray.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CFApplicationDirectory = 1, // supported applications (Applications)
|
||||
CFDemoApplicationDirectory, // unsupported applications, demonstration versions (Demos)
|
||||
CFDeveloperApplicationDirectory, // developer applications (Developer/Applications). DEPRECATED - there is no one single Developer directory.
|
||||
CFAdminApplicationDirectory, // system and network administration applications (Administration)
|
||||
CFLibraryDirectory, // various documentation, support, and configuration files, resources (Library)
|
||||
CFDeveloperDirectory, // developer resources (Developer) DEPRECATED - there is no one single Developer directory.
|
||||
CFUserDirectory, // user home directories (Users)
|
||||
CFDocumentationDirectory, // documentation (Documentation)
|
||||
CFDocumentDirectory, // documents (Documents)
|
||||
CFCoreServiceDirectory, // location of CoreServices directory (System/Library/CoreServices)
|
||||
CFAutosavedInformationDirectory = 11, // location of autosaved documents (Documents/Autosaved)
|
||||
CFDesktopDirectory = 12, // location of user's desktop
|
||||
CFCachesDirectory = 13, // location of discardable cache files (Library/Caches)
|
||||
CFApplicationSupportDirectory = 14, // location of application support files (plug-ins, etc) (Library/Application Support)
|
||||
CFDownloadsDirectory = 15, // location of the user's "Downloads" directory
|
||||
CFInputMethodsDirectory = 16, // input methods (Library/Input Methods)
|
||||
CFMoviesDirectory = 17, // location of user's Movies directory (~/Movies)
|
||||
CFMusicDirectory = 18, // location of user's Music directory (~/Music)
|
||||
CFPicturesDirectory = 19, // location of user's Pictures directory (~/Pictures)
|
||||
CFPrinterDescriptionDirectory = 20, // location of system's PPDs directory (Library/Printers/PPDs)
|
||||
CFSharedPublicDirectory = 21, // location of user's Public sharing directory (~/Public)
|
||||
CFPreferencePanesDirectory = 22, // location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes)
|
||||
CFApplicationScriptsDirectory = 23, // location of the user scripts folder for the calling application (~/Library/Application Scripts/code-signing-id)
|
||||
CFItemReplacementDirectory = 99, // For use with NSFileManager's URLForDirectory:inDomain:appropriateForURL:create:error:
|
||||
CFAllApplicationsDirectory = 100, // all directories where applications can occur
|
||||
CFAllLibrariesDirectory = 101, // all directories where resources can occur
|
||||
CFTrashDirectory = 102 // location of Trash directory
|
||||
} CFSearchPathDirectory;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CFUserDomainMask = 1, // user's home directory --- place to install user's personal items (~)
|
||||
CFLocalDomainMask = 2, // local to the current machine --- place to install items available to everyone on this machine (/Library)
|
||||
CFNetworkDomainMask = 4, // publically available location in the local area network --- place to install items available on the network (/Network)
|
||||
CFSystemDomainMask = 8, // provided by Apple, unmodifiable (/System)
|
||||
CFAllDomainsMask = 0x0ffff // all domains: all of the above and future items
|
||||
} CFDomainMask;
|
||||
|
||||
void CFSearchPathForDirectoriesInDomains(unsigned flags,
|
||||
unsigned domain_mask, unsigned expand_tilde, char *buf, size_t sizeof_buf);
|
||||
|
||||
void CFTemporaryDirectory(char *buf, size_t sizeof_buf);
|
||||
|
||||
#endif
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include "CFExtensions.h"
|
||||
#include "../../core_info.h"
|
||||
#include "../../playlist.h"
|
||||
#include "../../settings.h"
|
||||
|
@ -16,86 +16,7 @@
|
||||
|
||||
#import <AvailabilityMacros.h>
|
||||
#include <sys/stat.h>
|
||||
#include <CoreFoundation/CFArray.h>
|
||||
#include <CoreFoundation/CFString.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#include "cocoa_common.h"
|
||||
#include "../../general.h"
|
||||
#include "../../runloop.h"
|
||||
#include "../../frontend/frontend.h"
|
||||
#include "../../gfx/video_context_driver.h"
|
||||
|
||||
#ifndef __has_feature
|
||||
/* Compatibility with non-Clang compilers. */
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
|
||||
#ifndef CF_RETURNS_RETAINED
|
||||
#if __has_feature(attribute_cf_returns_retained)
|
||||
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
|
||||
#else
|
||||
#define CF_RETURNS_RETAINED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X)
|
||||
{
|
||||
#if __has_feature(objc_arc)
|
||||
return (__bridge_retained CFTypeRef)X;
|
||||
#else
|
||||
return X;
|
||||
#endif
|
||||
}
|
||||
|
||||
static NSSearchPathDirectory NSConvertFlagsCF(unsigned flags)
|
||||
{
|
||||
switch (flags)
|
||||
{
|
||||
case CFDocumentDirectory:
|
||||
return NSDocumentDirectory;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NSSearchPathDomainMask NSConvertDomainFlagsCF(unsigned flags)
|
||||
{
|
||||
switch (flags)
|
||||
{
|
||||
case CFUserDomainMask:
|
||||
return NSUserDomainMask;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CFTemporaryDirectory(char *buf, size_t sizeof_buf)
|
||||
{
|
||||
#if __has_feature(objc_arc)
|
||||
CFStringRef path = (__bridge_retained CFStringRef)NSTemporaryDirectory();
|
||||
#else
|
||||
CFStringRef path = (CFStringRef)NSTemporaryDirectory();
|
||||
#endif
|
||||
CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8);
|
||||
}
|
||||
|
||||
void CFSearchPathForDirectoriesInDomains(unsigned flags,
|
||||
unsigned domain_mask, unsigned expand_tilde,
|
||||
char *buf, size_t sizeof_buf)
|
||||
{
|
||||
CFTypeRef array_val = (CFTypeRef)CFBridgingRetainCompat(
|
||||
NSSearchPathForDirectoriesInDomains(NSConvertFlagsCF(flags),
|
||||
NSConvertDomainFlagsCF(domain_mask), (BOOL)expand_tilde));
|
||||
CFArrayRef array = array_val ? CFRetain(array_val) : NULL;
|
||||
CFTypeRef path_val = (CFTypeRef)CFArrayGetValueAtIndex(array, 0);
|
||||
CFStringRef path = path_val ? CFRetain(path_val) : NULL;
|
||||
if (!path || !array)
|
||||
return;
|
||||
|
||||
CFStringGetCString(path, buf, sizeof_buf, kCFStringEncodingUTF8);
|
||||
CFRelease(path);
|
||||
CFRelease(array);
|
||||
}
|
||||
|
||||
void apple_display_alert(const char *message, const char *title)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user