diff --git a/src/io.c b/src/io.c index a9ad9dd5..89862312 100644 --- a/src/io.c +++ b/src/io.c @@ -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) diff --git a/src/loadsavefuncs.c b/src/loadsavefuncs.c index d14f37b5..6dffba7c 100644 --- a/src/loadsavefuncs.c +++ b/src/loadsavefuncs.c @@ -93,8 +93,16 @@ FILE * Open_file_write(T_IO_Context *context) context->File_name[index] = '\0'; } } + else + { + GFX2_Log(GFX2_ERROR, "GetShortPathNameW(%p, %p, %u) failed !\n", filename_unicode, shortpath, len); + } } } + else + { + GFX2_Log(GFX2_ERROR, "GetShortPathNameW(%p, NULL, 0) failed !\n", filename_unicode); + } } free(filename_unicode); return f; diff --git a/src/osdep.c b/src/osdep.c index 263f2a7f..a4401683 100644 --- a/src/osdep.c +++ b/src/osdep.c @@ -599,7 +599,11 @@ bye: void GFX2_GetShortPathName(char * shortname, size_t shortname_len, const word * longname) { DWORD short_len = GetShortPathNameW((WCHAR *)longname, NULL, 0); - if (short_len > 0) + if (short_len == 0) + { + GFX2_Log(GFX2_ERROR, "GetShortPathNameW(%p, NULL, 0) failed !\n", longname); + } + else { WCHAR * temp_str = (WCHAR *)GFX2_malloc(short_len * sizeof(WCHAR)); short_len = GetShortPathNameW((WCHAR *)longname, temp_str, short_len); @@ -610,6 +614,10 @@ void GFX2_GetShortPathName(char * shortname, size_t shortname_len, const word * shortname[i] = temp_str[i]; shortname[i] = '\0'; } + else + { + GFX2_Log(GFX2_ERROR, "GetShortPathNameW(%p, %p, %u) failed !\n", longname, temp_str, short_len); + } free(temp_str); } if (short_len == 0) @@ -621,6 +629,7 @@ void GFX2_GetShortPathName(char * shortname, size_t shortname_len, const word * shortname[i] = (longname[i] < 256) ? (byte)longname[i] : '_'; } shortname[i] = '\0'; + GFX2_Log(GFX2_WARNING, "Generated a temporary ansi name : %s\n", shortname); } } #endif