Skip to content

Commit 204d4f0

Browse files
committed
[[ 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.
1 parent 23e0538 commit 204d4f0

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

docs/notes/bugfix-20282.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure 'the engine folder' returns a LiveCode path on Windows

engine/src/dskw32.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,12 +1936,24 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
19361936
else if (MCNameIsEqualTo(p_type, MCN_engine, kMCCompareCaseless)
19371937
|| MCNameIsEqualTo(p_type, MCN_resources, kMCCompareCaseless))
19381938
{
1939-
uindex_t t_last_slash;
1940-
1941-
if (!MCStringLastIndexOfChar(MCcmd, '/', UINDEX_MAX, kMCStringOptionCompareExact, t_last_slash))
1942-
t_last_slash = MCStringGetLength(MCcmd);
1939+
/* MCcmd is in LiveCode format, but this function actuall returns native
1940+
* paths so we just replicate what GetExecutablePath() does. */
1941+
WCHAR* wcFileNameBuf = new WCHAR[MAX_PATH+1];
1942+
DWORD dwFileNameLen = GetModuleFileNameW(NULL, wcFileNameBuf, MAX_PATH+1);
1943+
1944+
WCHAR* t_last_slash = wcsrchr(wcFileNameBuf, '\\');
1945+
if (t_last_slash != nullptr)
1946+
{
1947+
*t_last_slash = '\0';
1948+
}
19431949

1944-
return MCStringCopySubstring(MCcmd, MCRangeMake(0, t_last_slash), r_folder) ? True : False;
1950+
if (!MCStringCreateWithWStringAndRelease((unichar_t*)wcFileNameBuf, &t_native_path))
1951+
{
1952+
delete wcFileNameBuf;
1953+
return false;
1954+
}
1955+
1956+
t_wasfound = True;
19451957
}
19461958
else
19471959
{

0 commit comments

Comments
 (0)