2013-02-20 19:52:52 -05:00
/ * RetroArch - A frontend for libretro .
2014-01-01 01:50:59 +01:00
* Copyright ( C ) 2013 -2014 - Jason Fetters
* Copyright ( C ) 2011 -2014 - Daniel De Matteis
2013-02-20 19:52:52 -05:00
*
* 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 / > .
* /
2013-02-06 09:54:15 -05:00
2013-06-11 06:07:09 -04:00
# include < string . h >
2013-04-04 07:54:33 +02:00
2013-07-06 18:24:25 -04:00
# import "RetroArch_Apple.h"
2013-12-28 21:08:30 +01:00
# include "../../frontend/frontend.h"
2014-02-11 19:03:38 +11:00
# include "../../file.h"
2013-02-10 19:32:22 -05:00
2013-07-07 17:50:17 -04:00
id < RetroArch_Platform > apple_platform ;
2013-07-06 18:24:25 -04:00
# pragma mark EMULATION
2013-11-22 15:30:02 +01:00
NSString * apple_core ;
2013-07-06 18:24:25 -04:00
2014-05-03 07:17:59 +02:00
void apple_rarch _exited ( void )
2013-12-24 14:21:57 -05:00
{
2014-05-11 01:59:24 +02:00
NSString * used_core = ( NSString * ) apple_core ;
2013-12-24 14:21:57 -05:00
apple_core = 0 ;
2014-07-10 22:02:54 +02:00
[ apple_platform unloadingCore : used_core ] ;
2013-12-24 14:21:57 -05:00
2014-07-19 02:26:21 +02:00
# ifdef OSX
2013-12-24 14:21:57 -05:00
[ used_core release ] ;
2014-07-19 02:26:21 +02:00
# endif
2013-12-24 14:21:57 -05:00
}
2013-11-22 15:30:02 +01:00
void apple_run _core ( NSString * core , const char * file )
2013-07-06 18:24:25 -04:00
{
2014-05-12 15:17:08 +02:00
static char core_path [ PATH_MAX ] , file_path [ PATH_MAX ] , config_path [ PATH_MAX ] ;
char * * argv ;
int argc ;
2013-12-30 17:17:35 +01:00
[ apple_platform loadingCore : core withFile : file ] ;
apple_core = core ;
2014-01-03 17:16:02 -05:00
if ( file && core )
{
strlcpy ( core_path , apple_core . UTF8String , sizeof ( core_path ) ) ;
strlcpy ( file_path , file , sizeof ( file_path ) ) ;
}
2014-04-26 21:48:42 +02:00
if ( core_info _has _custom _config ( apple_core . UTF8String ) )
core_info _get _custom _config ( apple_core . UTF8String , config_path , sizeof ( config_path ) ) ;
2013-12-30 17:17:35 +01:00
else
2014-07-19 22:17:42 +02:00
strlcpy ( config_path , g_defaults . config_path , sizeof ( config_path ) ) ;
2013-12-30 17:17:35 +01:00
static const char * const argv_game [ ] = { "retroarch" , "-c" , config_path , "-L" , core_path , file_path , 0 } ;
static const char * const argv_menu [ ] = { "retroarch" , "-c" , config_path , "--menu" , 0 } ;
2014-05-12 15:17:08 +02:00
argc = ( file && core ) ? 6 : 4 ;
argv = ( char * * ) ( ( file && core ) ? argv_game : argv_menu ) ;
2014-01-03 17:16:02 -05:00
2014-06-01 23:06:17 +02:00
if ( apple_rarch _load _content ( & argc , argv ) )
2013-12-30 17:17:35 +01:00
{
char basedir [ 256 ] ;
fill_pathname _basedir ( basedir , file ? file : "" , sizeof ( basedir ) ) ;
if ( file && access ( basedir , R_OK | W_OK | X_OK ) )
2014-06-11 01:52:43 +02:00
apple_display _alert ( "The directory containing the selected file must have write permissions. This will prevent zipped content from loading, and will cause some cores to not function." , "Warning" ) ;
2013-12-30 17:17:35 +01:00
else
2014-05-03 21:34:13 +02:00
apple_display _alert ( "Failed to load content." , "Error" ) ;
2013-12-30 17:17:35 +01:00
apple_rarch _exited ( ) ;
}
2013-07-06 18:24:25 -04:00
}