Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit fda7c31

Browse files
committed
[Bug 19730] Added further tweaks and a stricter test
1 parent 676552f commit fda7c31

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

engine/src/dskmac.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

tests/lcs/core/files/files.livecodescript

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ on TestSpecialFolderPath
127127
put specialFolderPath("resources") into tResources
128128
if the platform is "macos" and the environment is "standalone" then
129129
// Standalone on Mac have their non-executable resource in a specific folder
130-
set the itemDelimiter to slash
131-
TestAssert "Resources folder on standalone Mac app in is Resources/_MacOS", item -2 to -1 of tResources is "Resources/_MacOS"
130+
TestAssert "Resources folder on standalone Mac app in is Resources/_MacOS", tResources ends with "Resources/_MacOS"
132131
else if the environment is "mobile" then
133132
testAssert "Resources and Engine specialfolderPaths are the same on mobile", tResources is tEngine
134133
else

0 commit comments

Comments
 (0)