Skip to content

Commit

Permalink
macos: fix some sandbox handling for app store (#17424)
Browse files Browse the repository at this point in the history
* minor safety check

* macos: fix some sandbox handling for app store
  • Loading branch information
warmenhoven authored Jan 17, 2025
1 parent dda78a4 commit 2471082
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
4 changes: 2 additions & 2 deletions frontend/drivers/platform_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ static enum frontend_architecture frontend_darwin_get_arch(void)
static int frontend_darwin_parse_drive_list(void *data, bool load_content)
{
int ret = -1;
#if TARGET_OS_IPHONE
#if TARGET_OS_IPHONE || defined(HAVE_APPLE_STORE)
#ifdef HAVE_MENU
struct string_list *str_list = NULL;
file_list_t *list = (file_list_t*)data;
Expand Down Expand Up @@ -733,7 +733,7 @@ static int frontend_darwin_parse_drive_list(void *data, bool load_content)
FILE_TYPE_DIRECTORY, 0, 0, NULL);
string_list_free(str_list);

#if TARGET_OS_IOS
#if !TARGET_OS_TV
if ( filebrowser_get_type() == FILEBROWSER_NONE ||
filebrowser_get_type() == FILEBROWSER_SCAN_FILE ||
filebrowser_get_type() == FILEBROWSER_SELECT_FILE)
Expand Down
5 changes: 4 additions & 1 deletion menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -6467,9 +6467,12 @@ static int action_ok_open_uwp_permission_settings(const char *path,
static int action_ok_open_picker(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
#if TARGET_OS_IOS
#ifdef IOS
ios_show_file_sheet();
return 0;
#elif defined(OSX) && defined(HAVE_APPLE_STORE)
osx_show_file_sheet();
return 0;
#else
char *new_path = NULL;
int ret = generic_action_ok_displaylist_push(
Expand Down
4 changes: 2 additions & 2 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ static int filebrowser_parse(
MENU_ENUM_LABEL_NO_ITEMS,
MENU_SETTING_NO_ITEM, 0, 0, NULL);

#ifdef IOS
#if defined(IOS) || (defined(OSX) && defined(HAVE_APPLE_STORE))
{
/* Check if we're allowed to escape our sandbox */
struct string_list *str_list = string_list_new();
Expand Down Expand Up @@ -5154,7 +5154,7 @@ static unsigned menu_displaylist_parse_content_information(
db_name,
sizeof(db_path));
last = path_get_extension_mutable(db_path);
if (*last)
if (last && *last)
{
last[0] = '.';
last[1] = 'r';
Expand Down
5 changes: 5 additions & 0 deletions ui/drivers/cocoa/apple_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ extern void ios_show_file_sheet(void);
extern bool ios_running_on_ipad(void);
#endif

#if TARGET_OS_OSX
extern void osx_show_file_sheet(void);
#endif

#ifdef __OBJC__

#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -56,6 +60,7 @@ typedef enum apple_view_type
* the displays should not sleep.
*/
- (bool)setDisableDisplaySleep:(bool)disable;
- (void)openDocument:(id)sender;
@end

#endif
Expand Down
7 changes: 7 additions & 0 deletions ui/drivers/cocoa/cocoa_common.m
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,13 @@ void ios_show_file_sheet(void)
}
#endif

#if TARGET_OS_OSX && defined(HAVE_APPLE_STORE)
void osx_show_file_sheet(void)
{
[apple_platform openDocument:nil];
}
#endif

void *cocoa_screen_get_chosen(void)
{
unsigned monitor_index;
Expand Down
25 changes: 16 additions & 9 deletions ui/drivers/ui_cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -918,16 +918,23 @@ static void open_document_handler(
if (!result)
return;

path_set(RARCH_PATH_CONTENT, state->result);

if (core_name)
if (filebrowser_get_type() == FILEBROWSER_SCAN_FILE)
action_scan_file(state->result, NULL, 0, 0);
else
{
content_ctx_info_t content_info = {0};
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
path_set(RARCH_PATH_CONTENT, state->result);

if (!string_is_empty(core_name))
{
content_ctx_info_t content_info = {0};
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
}
else
cocoa_file_load_with_detect_core(state->result);
}
}

Expand Down

0 comments on commit 2471082

Please sign in to comment.