Mercurial > pidgin.yaz
changeset 31354:4de2b3adc823
Make untarring work for non-ASCII destination dirs on Windows.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 04 Nov 2010 19:20:38 +0000 |
parents | 3c1563a54785 |
children | d9db23719cf9 |
files | pidgin/win32/untar.c |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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);