Log errors of GetShortPathNameW/GetLongPathNameW

This commit is contained in:
Thomas Bernard
2020-12-05 15:09:38 +01:00
parent 100776eca7
commit 0915f86aa3
3 changed files with 27 additions and 2 deletions

View File

@@ -809,15 +809,23 @@ word * Get_Unicode_Filename(word * filename_unicode, const char * filename, cons
len = GetLongPathNameW(shortPath, NULL, 0);
if (len == 0)
{
GFX2_Log(GFX2_ERROR, "GetLongPathNameW(%s\\%s, NULL, 0) returned 0\n", directory, filename);
free(shortPath);
return NULL;
}
longPath = (WCHAR *)GFX2_malloc(len * sizeof(WCHAR));
if (longPath == NULL || GetLongPathNameW(shortPath, longPath, len) == 0)
if (longPath == NULL)
{
free(shortPath);
return NULL;
}
if (GetLongPathNameW(shortPath, longPath, len) == 0)
{
GFX2_Log(GFX2_ERROR, "GetLongPathNameW(%s\\%s, %p, %u) returned 0\n", directory, filename, longPath, len);
free(longPath);
free(shortPath);
return NULL;
}
free(shortPath);
sep = wcsrchr(longPath, '\\');
if (sep == NULL)