@@ -917,11 +917,23 @@ static bool MCS_apply_redirect(MCStringRef p_path, bool p_is_file, MCStringRef&
917917 MCAutoStringRef t_new_path;
918918 MCRange t_cmd_range, t_path_range;
919919 t_cmd_range = MCRangeMake (0 , t_engine_path_length - 6 );
920- t_path_range = MCRangeMake (t_engine_path_length + 1 , UINDEX_MAX);
921-
922- // AL-2014-09-19: Range argument to MCStringFormat is a pointer to an MCRange.
923- /* UNCHECKED */ MCStringFormat (&t_new_path, " %*@/Resources/_MacOS/%*@" , &t_cmd_range, MCcmd, &t_path_range, p_path);
924-
920+
921+ uindex_t t_path_end = MCStringGetLength (p_path);
922+ if (MCStringGetCodepointAtIndex (p_path, t_path_end) == ' /' )
923+ t_path_end--;
924+
925+ t_path_range = MCRangeMakeMinMax (t_engine_path_length + 1 , t_path_end);
926+
927+ if (t_engine_path_length == t_path_end)
928+ {
929+ MCStringFormat (&t_new_path, " %*@/Resources/_MacOS" , &t_cmd_range, MCcmd);
930+ }
931+ else
932+ {
933+ // AL-2014-09-19: Range argument to MCStringFormat is a pointer to an MCRange.
934+ MCStringFormat (&t_new_path, " %*@/Resources/_MacOS/%*@" , &t_cmd_range, MCcmd, &t_path_range, p_path);
935+ }
936+
925937 if (p_is_file && !MCS_file_exists_at_path (*t_new_path))
926938 return false ;
927939
@@ -3513,16 +3525,8 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
35133525 if (MCNameIsEqualTo (p_type, MCN_resources, kMCCompareCaseless ))
35143526 {
35153527 MCAutoStringRef t_resources_folder;
3516- if (!MCS_apply_redirect (*t_engine_folder, false , &t_resources_folder ))
3528+ if (!MCS_apply_redirect (*t_engine_folder, false , r_folder ))
35173529 return False;
3518-
3519- if (MCStringEndsWith (*t_resources_folder, MCSTR (" /" ), kMCCompareExact ))
3520- {
3521- MCStringCopySubstring (*t_resources_folder, MCRangeMake (0 , MCStringGetLength (*t_resources_folder) - 1 ), r_folder);
3522- }
3523- else
3524- r_folder = MCValueRetain (*t_resources_folder);
3525-
35263530 }
35273531 else
35283532 r_folder = MCValueRetain (*t_engine_folder);
0 commit comments