From Stephan Hunber, "I found some time and ported osgDB::FileUtils and DarwinUtils across new apis to fix the warnings about deprecated api-usage.
* osgDB::FileUtils uses now the Cocoa-API to determine the paths of the application-support-folder * DarwinUtils uses now modern functions of the quartz-api to get and set screen-resolutions. Removed some of the osg-deprecated stuff. "
This commit is contained in:
@@ -51,6 +51,7 @@ typedef char TCHAR;
|
||||
//>OSG_IOS
|
||||
//IOS includes
|
||||
#include "TargetConditionals.h"
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if (TARGET_OS_IPHONE)
|
||||
#include <Availability.h>
|
||||
@@ -85,6 +86,10 @@ typedef char TCHAR;
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(_DARWIN_FEATURE_64_BIT_INODE)
|
||||
#define stat64 stat
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// set up _S_ISDIR()
|
||||
@@ -868,7 +873,7 @@ bool osgDB::containsCurrentWorkingDirectoryReference(const FilePathList& paths)
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#if (TARGET_OS_IPHONE)
|
||||
#if (TARGET_OS_IPHONE) || (MAC_OS_X_VERSION_MIN_REQUIRED >= 1080)
|
||||
#define COMPILE_COCOA_VERSION
|
||||
#else
|
||||
#define COMPILE_CARBON_VERSION
|
||||
@@ -1006,7 +1011,7 @@ bool osgDB::containsCurrentWorkingDirectoryReference(const FilePathList& paths)
|
||||
}
|
||||
|
||||
appendInstallationLibraryFilePaths(filepath);
|
||||
|
||||
|
||||
// Since this is currently the only Objective-C code in the
|
||||
// library, we need an autoreleasepool for obj-c memory management.
|
||||
// If more Obj-C is added, we might move this pool to another
|
||||
@@ -1016,29 +1021,28 @@ bool osgDB::containsCurrentWorkingDirectoryReference(const FilePathList& paths)
|
||||
NSAutoreleasePool* mypool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString* myBundlePlugInPath;
|
||||
NSString* userSupportDir;
|
||||
|
||||
// This will grab the "official" bundle plug in path.
|
||||
// It will be YourProgram.app/Contents/PlugIns (for App bundles)
|
||||
// or YourProgram/PlugIns (for Unix executables)
|
||||
myBundlePlugInPath = [[NSBundle mainBundle] builtInPlugInsPath];
|
||||
|
||||
// Now setup the other search paths
|
||||
// Cocoa has a nice method for tilde expansion.
|
||||
// There's probably a better way of getting this directory, but I
|
||||
// can't find the call.
|
||||
userSupportDir = [@"~/Library/Application Support/OpenSceneGraph/PlugIns" stringByExpandingTildeInPath];
|
||||
|
||||
// Can setup the remaining directories directly in C++
|
||||
|
||||
// Since Obj-C and C++ objects don't understand each other,
|
||||
// the Obj-C strings must be converted down to C strings so
|
||||
// C++ can make them into C++ strings.
|
||||
filepath.push_back( [myBundlePlugInPath UTF8String] );
|
||||
filepath.push_back( [userSupportDir UTF8String] );
|
||||
|
||||
// add all application-support-folders
|
||||
NSArray *systemSearchPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSAllDomainsMask, YES);
|
||||
|
||||
filepath.push_back( "/Library/Application Support/OpenSceneGraph/PlugIns" );
|
||||
filepath.push_back( "/Network/Library/Application Support/OpenSceneGraph/PlugIns" );
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
|
||||
for (NSString *systemPath in systemSearchPaths) {
|
||||
NSString *systemPluginsPath = [systemPath stringByAppendingPathComponent:@"OpenSceneGraph/PlugIns"];
|
||||
if ([fileManager fileExistsAtPath:systemPluginsPath]) {
|
||||
filepath.push_back( [systemPluginsPath UTF8String] );
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up the autorelease pool
|
||||
[mypool release];
|
||||
@@ -1107,71 +1111,29 @@ bool osgDB::containsCurrentWorkingDirectoryReference(const FilePathList& paths)
|
||||
}
|
||||
|
||||
// Next, check the User's Application Support folder
|
||||
errCode = FSFindFolder( kUserDomain, kApplicationSupportFolderType, kDontCreateFolder, &f );
|
||||
if(noErr == errCode)
|
||||
int domains[3] = { kUserDomain, kLocalDomain, kNetworkDomain };
|
||||
|
||||
for(unsigned int domain_ndx = 0; domain_ndx < 3; ++domain_ndx)
|
||||
{
|
||||
// Get the URL
|
||||
url = CFURLCreateFromFSRef( 0, &f );
|
||||
if(url)
|
||||
errCode = FSFindFolder( domains[domain_ndx], kApplicationSupportFolderType, kDontCreateFolder, &f );
|
||||
if(noErr == errCode)
|
||||
{
|
||||
filepath.push_back(GetPathFromCFURLRef(url) + OSG_PLUGIN_PATH);
|
||||
CFRelease( url );
|
||||
// Get the URL
|
||||
url = CFURLCreateFromFSRef( 0, &f );
|
||||
if(url)
|
||||
{
|
||||
filepath.push_back(GetPathFromCFURLRef(url) + OSG_PLUGIN_PATH);
|
||||
CFRelease( url );
|
||||
}
|
||||
else
|
||||
OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't create CFURLRef for application support Path at ndx " << domain_ndx << std::endl;
|
||||
|
||||
url = NULL;
|
||||
}
|
||||
else
|
||||
OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't create CFURLRef for User's application support Path" << std::endl;
|
||||
|
||||
url = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't find the User's Application Support Path" << std::endl;
|
||||
}
|
||||
|
||||
// Next, check the Local System's Application Support Folder
|
||||
errCode = FSFindFolder( kLocalDomain, kApplicationSupportFolderType, kDontCreateFolder, &f );
|
||||
if(noErr == errCode)
|
||||
{
|
||||
// Get the URL
|
||||
url = CFURLCreateFromFSRef( 0, &f );
|
||||
|
||||
if(url)
|
||||
{
|
||||
filepath.push_back(GetPathFromCFURLRef(url) + OSG_PLUGIN_PATH);
|
||||
CFRelease( url );
|
||||
OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't find the User's Application Support Path at ndx " << domain_ndx << std::endl;
|
||||
}
|
||||
else
|
||||
OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't create CFURLRef for local System's ApplicationSupport Path" << std::endl;
|
||||
|
||||
url = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't find the Local System's Application Support Path" << std::endl;
|
||||
}
|
||||
|
||||
// Finally, check the Network Application Support Folder
|
||||
// This one has a likely chance of not existing so an error
|
||||
// may be returned. Don't panic.
|
||||
errCode = FSFindFolder( kNetworkDomain, kApplicationSupportFolderType, kDontCreateFolder, &f );
|
||||
if(noErr == errCode)
|
||||
{
|
||||
// Get the URL
|
||||
url = CFURLCreateFromFSRef( 0, &f );
|
||||
|
||||
if(url)
|
||||
{
|
||||
filepath.push_back(GetPathFromCFURLRef(url) + OSG_PLUGIN_PATH);
|
||||
CFRelease( url );
|
||||
}
|
||||
else
|
||||
OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't create CFURLRef for network Application Support Path" << std::endl;
|
||||
|
||||
url = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// had to comment out as it segfauls the OSX app otherwise
|
||||
// OSG_NOTIFY( osg::DEBUG_INFO ) << "Couldn't find the Network Application Support Path" << std::endl;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user