Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 468d99e

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
fix SystemImpl__directoryExists for Windows, cannot end in (forward) slash
1 parent 558fab0 commit 468d99e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Compiler/runtime/systemimpl.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,12 @@ extern int SystemImpl__directoryExists(const char *str)
853853
#if defined(__MINGW32__) || defined(_MSC_VER)
854854
WIN32_FIND_DATA FileData;
855855
HANDLE sh;
856-
sh = FindFirstFile(str, &FileData);
856+
char* path = strdup(str);
857+
int last = strlen(path)-1;
858+
/* adrpo: RTFM! the path cannot end in a slash??!! https://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx */
859+
if (last > 0 && (path[last] == '\\' || path[last] == '/')) path[last] = '\0';
860+
sh = FindFirstFile(path, &FileData);
861+
free(path);
857862
if (sh == INVALID_HANDLE_VALUE)
858863
return 0;
859864
FindClose(sh);

0 commit comments

Comments
 (0)