Different behaviour between git and 0.20.2 with wide char
Hello everyone,
I come with a small question. Indeed, I'm using libraw in my project and everything is fine. However I recently found a small glitch if I use the git version and not the 0.20.2 version.
To handle wide char filenames I use a function to convert them and it was ok until now. It looks like the git version has changed some behaviour.
char* get_real_path(const char *source) { HANDLE hFile; DWORD maxchar = 2048; wchar_t *wsource = g_utf8_to_utf16(source, -1, NULL, NULL, NULL); if ( wsource == NULL ) { return NULL ; } if (!(GetFileAttributesW(wsource) & FILE_ATTRIBUTE_REPARSE_POINT)) { g_free(wsource); return NULL; } wchar_t *wFilePath = g_new(wchar_t, maxchar + 1); if (!wFilePath) { PRINT_ALLOC_ERR; g_free(wsource); return NULL; } wFilePath[0] = 0; hFile = CreateFileW(wsource, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile == INVALID_HANDLE_VALUE) { g_free(wFilePath); g_free(wsource); return NULL; } GetFinalPathNameByHandleW(hFile, wFilePath, maxchar, 0); gchar *gFilePath = g_utf16_to_utf8(wFilePath + 4, -1, NULL, NULL, NULL); // +4 = enleve les 4 caracteres du prefixe "//?/" g_free(wsource); g_free(wFilePath); CloseHandle(hFile); return gFilePath; }
Could you tell me more about that? Is it a bug? The only thing I change is the LibRaw version, nothing else. In one case I can open wide char filename, in other case I can't.
My best regards, and thanks again for your work.
Recent comments