# HG changeset patch # User Daniel Atallah # Date 1288898438 0 # Node ID 4de2b3adc823cee51526479e07d104292d1b864b # Parent 3c1563a54785975c7d721a2c6209eac27cfcd84a Make untarring work for non-ASCII destination dirs on Windows. diff -r 3c1563a54785 -r 4de2b3adc823 pidgin/win32/untar.c --- a/pidgin/win32/untar.c Thu Nov 04 18:23:41 2010 +0000 +++ b/pidgin/win32/untar.c Thu Nov 04 19:20:38 2010 +0000 @@ -578,7 +578,8 @@ */ int untar(const char *filename, const char* destdir, untar_opt options) { int ret=1; - char curdir[_MAX_PATH]; + wchar_t curdir[_MAX_PATH]; + wchar_t *w_destdir; untarops = options; /* open the archive */ inname = filename; @@ -589,13 +590,15 @@ return 0; } + w_destdir = g_utf8_to_utf16(destdir, -1, NULL, NULL, NULL); + /* Set current directory */ - if(!GetCurrentDirectory(_MAX_PATH, curdir)) { + if(!GetCurrentDirectoryW(_MAX_PATH, curdir)) { untar_error("Could not get current directory (error %lu).\n", GetLastError()); fclose(infp); return 0; } - if(!SetCurrentDirectory(destdir)) { + if(!SetCurrentDirectoryW(w_destdir)) { untar_error("Could not set current directory to (error %lu): %s\n", GetLastError(), destdir); fclose(infp); return 0; @@ -614,12 +617,14 @@ fclose(outfp); outfp = NULL; } - if(!SetCurrentDirectory(curdir)) { + if(!SetCurrentDirectoryW(curdir)) { untar_error("Could not set current dir back to original (error %lu).\n", GetLastError()); ret=0; } } + g_free(w_destdir); + /* close the archive file. */ fclose(infp);