Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions engine/src/dskmac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <Security/Authorization.h>
#include <Security/AuthorizationTags.h>

#include <mach-o/dyld.h>

#define ENTRIES_CHUNK 1024

Expand Down Expand Up @@ -656,7 +657,9 @@ static sysfolders sysfolderlist[] = {
// MW-2007-09-11: Added for uniformity across platforms
{&MCN_documents, 'docs', kUserDomain, 'docs'},
// MW-2007-10-08: [[ Bug 10277 ] Add support for the 'application support' at user level.
{&MCN_support, 0, kUserDomain, 'asup'},
// SN-2014-07-30: [[ Bug 13026 ]] We don't want any folder which doesn't match one above
// to return the Application Support folder
{&MCN_support, 'asup', kUserDomain, 'asup'},
};

static bool MCS_mac_specialfolder_to_mac_folder(MCStringRef p_type, uint32_t& r_folder, OSType& r_domain)
Expand Down Expand Up @@ -5439,6 +5442,10 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
const char *t_error;
t_error = NULL;

// SN-2014-07-30: [[ 13026 ]] We can get the engine folder on desktop as well
char *t_folder_path;
t_folder_path = NULL;

FSRef t_folder_ref;
if (t_error == NULL)
{
Expand All @@ -5451,8 +5458,15 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
memcpy(&t_mac_folder, p_context . getsvalue() . getstring(), 4);
t_mac_folder = MCSwapInt32NetworkToHost(t_mac_folder);
}
else
else if (p_context . getsvalue() == "engine")
{
extern char *MCcmd;
char* t_folder;
t_folder_path = strndup(MCcmd, strrchr(MCcmd, '/') - MCcmd);

t_mac_folder = 0;
t_found_folder = true;
}

OSErr t_os_error;
uint2 t_i;
Expand Down Expand Up @@ -5483,10 +5497,9 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
if (!t_found_folder)
t_error = "folder not found";
}

char *t_folder_path;
t_folder_path = NULL;
if (t_error == NULL)

// SN-2014-07-30: [[ Bug 13026 ]] If the engine was asked, the folder path is directly set
if (t_error == NULL && t_folder_path == NULL)
{
t_folder_path = MCS_fsref_to_path(t_folder_ref);
if (t_folder_path == NULL)
Expand Down Expand Up @@ -5516,6 +5529,14 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
t_domain = kOnAppropriateDisk;
t_found_folder = true;
}
else if (MCNameIsEqualTo(p_type, MCN_engine))
{
extern MCStringRef MCcmd;
uindex_t t_last_slash;
if (!MCStringLastIndexOfChar(MCcmd, '/', UINDEX_MAX, kMCCompareCaseless, t_last_slash))
t_last_slash = MCStringGetLength(MCcmd);
return MCStringCopySubstring(MCcmd, MCRangeMake(0, t_last_slash), r_folder);
}

FSRef t_folder_ref;
if (t_found_folder)
Expand Down
13 changes: 13 additions & 0 deletions engine/src/dskw32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2682,6 +2682,19 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
t_wasfound = true;
}
}
}
// SN-2014-07-30: [[ Bug 13026 ]] specialFolderPath("engine") added for Windows
else if (MCNameIsEqualTo(p_type, MCN_engine))
{
extern MCStringRef MCcmd;
uindex_t t_last_slash;
if (!MCStringLastIndexOfChar(MCcmd, '/', UINDEX_MAX, kMCCompareCaseless, t_last_slash))
t_last_slash = MCStringGetLength(MCcmd);
MCAutoStringRef t_path;
if (!MCStringCopySubstring(MCcmd, MCRangeMake(0, t_last_slash), &t_path) ||
!MCU_path2native(*t_path, &t_native_path))
return false;
t_wasfound = true;
}
//else if (MCStringIsEqualTo(p_special, MCNameGetString(MCN_system), kMCStringOptionCompareCaseless))
//{
Expand Down