Skip to content

Commit

Permalink
fix SystemImpl__directoryExists for Windows, cannot end in (forward) …
Browse files Browse the repository at this point in the history
…slash
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Dec 21, 2016
1 parent 558fab0 commit 468d99e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Compiler/runtime/systemimpl.c
Expand Up @@ -853,7 +853,12 @@ extern int SystemImpl__directoryExists(const char *str)
#if defined(__MINGW32__) || defined(_MSC_VER)
WIN32_FIND_DATA FileData;
HANDLE sh;
sh = FindFirstFile(str, &FileData);
char* path = strdup(str);
int last = strlen(path)-1;
/* adrpo: RTFM! the path cannot end in a slash??!! https://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx */
if (last > 0 && (path[last] == '\\' || path[last] == '/')) path[last] = '\0';
sh = FindFirstFile(path, &FileData);
free(path);
if (sh == INVALID_HANDLE_VALUE)
return 0;
FindClose(sh);
Expand Down

0 comments on commit 468d99e

Please sign in to comment.