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

Commit

Permalink
Auto-merge pull request #5881 from runrevmark/bugfix-20282
Browse files Browse the repository at this point in the history
[[ Bug 20282 ]] Ensure 'the engine folder' returns a LiveCode path

This patch fixes an issue where 'the engine folder' would return a
native looking path on Windows. The use of MCcmd has been replaced
with a direct query of the executable module's filename.

Note: This fix is pertinent to 8 - a slightly different patch is needed for 9.
  • Loading branch information
livecode-vulcan committed Aug 31, 2017
2 parents 2dc2938 + 204d4f0 commit fc66336
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/notes/bugfix-20282.md
@@ -0,0 +1 @@
# Ensure 'the engine folder' returns a LiveCode path on Windows
22 changes: 17 additions & 5 deletions engine/src/dskw32.cpp
Expand Up @@ -1936,12 +1936,24 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
else if (MCNameIsEqualTo(p_type, MCN_engine, kMCCompareCaseless)
|| MCNameIsEqualTo(p_type, MCN_resources, kMCCompareCaseless))
{
uindex_t t_last_slash;

if (!MCStringLastIndexOfChar(MCcmd, '/', UINDEX_MAX, kMCStringOptionCompareExact, t_last_slash))
t_last_slash = MCStringGetLength(MCcmd);
/* MCcmd is in LiveCode format, but this function actuall returns native
* paths so we just replicate what GetExecutablePath() does. */
WCHAR* wcFileNameBuf = new WCHAR[MAX_PATH+1];
DWORD dwFileNameLen = GetModuleFileNameW(NULL, wcFileNameBuf, MAX_PATH+1);

WCHAR* t_last_slash = wcsrchr(wcFileNameBuf, '\\');
if (t_last_slash != nullptr)
{
*t_last_slash = '\0';
}

return MCStringCopySubstring(MCcmd, MCRangeMake(0, t_last_slash), r_folder) ? True : False;
if (!MCStringCreateWithWStringAndRelease((unichar_t*)wcFileNameBuf, &t_native_path))
{
delete wcFileNameBuf;
return false;
}

t_wasfound = True;
}
else
{
Expand Down

0 comments on commit fc66336

Please sign in to comment.