Skip to content

Commit

Permalink
Merge pull request #3490 from patrickbkr/fix-unicode-paths-windows
Browse files Browse the repository at this point in the history
Fix Rakudo running in unicode paths on Windows again
  • Loading branch information
patrickbkr committed Feb 17, 2020
2 parents 6844be9 + 4c6cd03 commit 1cc43c8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/vm/moar/runner/main.c
Expand Up @@ -72,8 +72,14 @@ static int parse_flag(const char *arg)

int file_exists(const char *path) {
#ifdef _WIN32
struct _stat sb;
return _stat(path, &sb) == 0;
int res;
struct _stat sb;
const int len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
wchar_t * const wpath = (wchar_t *)malloc(len * sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, path, -1, (LPWSTR)wpath, len);
res = _wstat(wpath, &sb);
MVM_free(wpath);
return res == 0;
#else
struct stat *sb = malloc(sizeof(struct stat));
int res = stat(path, sb) == 0;
Expand Down

0 comments on commit 1cc43c8

Please sign in to comment.