For iOS, build the Mac OS X platform code, not the generic Unix code.
Also removed some Carbon calls; use CoreFoundation instead. These functions exist in all versions of Mac OS X and iOS, and replace the Mac OS Classic APIs we were previously depending upon.
This commit is contained in:
parent
2a4d891ac5
commit
bbbbb17258
|
@ -29,13 +29,10 @@
|
||||||
/* To check if iphone or not, we need to include this file */
|
/* To check if iphone or not, we need to include this file */
|
||||||
# include <TargetConditionals.h>
|
# include <TargetConditionals.h>
|
||||||
# if ((TARGET_IPHONE_SIMULATOR) || (TARGET_OS_IPHONE))
|
# if ((TARGET_IPHONE_SIMULATOR) || (TARGET_OS_IPHONE))
|
||||||
# define PHYSFS_PLATFORM_UNIX 1
|
|
||||||
# define PHYSFS_PLATFORM_POSIX 1
|
|
||||||
# define PHYSFS_NO_CDROM_SUPPORT 1
|
# define PHYSFS_NO_CDROM_SUPPORT 1
|
||||||
# else
|
# endif
|
||||||
# define PHYSFS_PLATFORM_MACOSX 1
|
# define PHYSFS_PLATFORM_MACOSX 1
|
||||||
# define PHYSFS_PLATFORM_POSIX 1
|
# define PHYSFS_PLATFORM_POSIX 1
|
||||||
# endif
|
|
||||||
#elif defined(macintosh)
|
#elif defined(macintosh)
|
||||||
# error Classic Mac OS support was dropped from PhysicsFS 2.0. Move to OS X.
|
# error Classic Mac OS support was dropped from PhysicsFS 2.0. Move to OS X.
|
||||||
#elif defined(__linux)
|
#elif defined(__linux)
|
||||||
|
|
|
@ -11,11 +11,15 @@
|
||||||
|
|
||||||
#ifdef PHYSFS_PLATFORM_MACOSX
|
#ifdef PHYSFS_PLATFORM_MACOSX
|
||||||
|
|
||||||
#include <Carbon/Carbon.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
|
#if !defined(PHYSFS_NO_CDROM_SUPPORT)
|
||||||
#include <IOKit/storage/IOMedia.h>
|
#include <IOKit/storage/IOMedia.h>
|
||||||
#include <IOKit/storage/IOCDMedia.h>
|
#include <IOKit/storage/IOCDMedia.h>
|
||||||
#include <IOKit/storage/IODVDMedia.h>
|
#include <IOKit/storage/IODVDMedia.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
/* Seems to get defined in some system header... */
|
/* Seems to get defined in some system header... */
|
||||||
|
@ -80,6 +84,7 @@ int __PHYSFS_platformDeinit(void)
|
||||||
} /* __PHYSFS_platformDeinit */
|
} /* __PHYSFS_platformDeinit */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* CD-ROM detection code... */
|
/* CD-ROM detection code... */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -87,6 +92,8 @@ int __PHYSFS_platformDeinit(void)
|
||||||
* http://developer.apple.com/samplecode/Sample_Code/Devices_and_Hardware/Disks/VolumeToBSDNode/VolumeToBSDNode.c.htm
|
* http://developer.apple.com/samplecode/Sample_Code/Devices_and_Hardware/Disks/VolumeToBSDNode/VolumeToBSDNode.c.htm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(PHYSFS_NO_CDROM_SUPPORT)
|
||||||
|
|
||||||
static int darwinIsWholeMedia(io_service_t service)
|
static int darwinIsWholeMedia(io_service_t service)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
@ -161,9 +168,12 @@ static int darwinIsMountedDisc(char *bsdName, mach_port_t masterPort)
|
||||||
return retval;
|
return retval;
|
||||||
} /* darwinIsMountedDisc */
|
} /* darwinIsMountedDisc */
|
||||||
|
|
||||||
|
#endif /* !defined(PHYSFS_NO_CDROM_SUPPORT) */
|
||||||
|
|
||||||
|
|
||||||
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
||||||
{
|
{
|
||||||
|
#if !defined(PHYSFS_NO_CDROM_SUPPORT)
|
||||||
const char *devPrefix = "/dev/";
|
const char *devPrefix = "/dev/";
|
||||||
const int prefixLen = strlen(devPrefix);
|
const int prefixLen = strlen(devPrefix);
|
||||||
mach_port_t masterPort = 0;
|
mach_port_t masterPort = 0;
|
||||||
|
@ -185,6 +195,7 @@ void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
|
||||||
if (darwinIsMountedDisc(dev, masterPort))
|
if (darwinIsMountedDisc(dev, masterPort))
|
||||||
cb(data, mnt);
|
cb(data, mnt);
|
||||||
} /* for */
|
} /* for */
|
||||||
|
#endif /* !defined(PHYSFS_NO_CDROM_SUPPORT) */
|
||||||
} /* __PHYSFS_platformDetectAvailableCDs */
|
} /* __PHYSFS_platformDetectAvailableCDs */
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,9 +230,7 @@ static char *convertCFString(CFStringRef cfstr)
|
||||||
|
|
||||||
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
{
|
{
|
||||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
FSRef fsref;
|
|
||||||
CFRange cfrange;
|
CFRange cfrange;
|
||||||
CFURLRef cfurl = NULL;
|
CFURLRef cfurl = NULL;
|
||||||
CFStringRef cfstr = NULL;
|
CFStringRef cfstr = NULL;
|
||||||
|
@ -230,9 +239,7 @@ char *__PHYSFS_platformCalcBaseDir(const char *argv0)
|
||||||
char *cstr = NULL;
|
char *cstr = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (GetProcessBundleLocation(&psn, &fsref) != noErr)
|
cfurl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||||
BAIL_MACRO(PHYSFS_ERR_OS_ERROR, NULL);
|
|
||||||
cfurl = CFURLCreateFromFSRef(cfallocator, &fsref);
|
|
||||||
BAIL_IF_MACRO(cfurl == NULL, PHYSFS_ERR_OS_ERROR, NULL);
|
BAIL_IF_MACRO(cfurl == NULL, PHYSFS_ERR_OS_ERROR, NULL);
|
||||||
cfstr = CFURLCopyFileSystemPath(cfurl, kCFURLPOSIXPathStyle);
|
cfstr = CFURLCopyFileSystemPath(cfurl, kCFURLPOSIXPathStyle);
|
||||||
CFRelease(cfurl);
|
CFRelease(cfurl);
|
||||||
|
|
Loading…
Reference in New Issue