1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

gpgtar,w32: Fix gpgtar 8 bit encoding handling on W32

* common/utf8conv.c (wchar_to_utf8): Factor code out to ...
(wchar_to_cp): new.
(utf8_to_wchar): Factor code out to ...
(cp_to_wchar): new.
(wchar_to_native): New.
(native_to_wchar): New.
* tools/gpgtar-create.c (fillup_entry_w32): Use native_to_wchar.
(scan_directory): Use wchar_to_native.
--

Gpgtar needs to handle filenames in the local 8 bit encoding on
Windows as it uses the 8 bit file io functions.

GnuPG-bug-id: 1624, 1746

Patch from bug 1624 modified to fit into GnuPG 2.1 by wk.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Andre Heinecke 2016-01-26 09:53:42 +01:00 committed by Werner Koch
parent b8bb16c6c0
commit 3e50236d4e
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
3 changed files with 62 additions and 15 deletions

View file

@ -72,13 +72,13 @@ fillup_entry_w32 (tar_header_t hdr)
for (p=hdr->name; *p; p++)
if (*p == '/')
*p = '\\';
wfname = utf8_to_wchar (hdr->name);
wfname = native_to_wchar (hdr->name);
for (p=hdr->name; *p; p++)
if (*p == '\\')
*p = '/';
if (!wfname)
{
log_error ("error utf8-ing '%s': %s\n", hdr->name, w32_strerror (-1));
log_error ("error converting '%s': %s\n", hdr->name, w32_strerror (-1));
return gpg_error_from_syserror ();
}
if (!GetFileAttributesExW (wfname, GetFileExInfoStandard, &fad))
@ -299,7 +299,7 @@ scan_directory (const char *dname, scanctrl_t scanctrl)
for (p=fname; *p; p++)
if (*p == '/')
*p = '\\';
wfname = utf8_to_wchar (fname);
wfname = native_to_wchar (fname);
xfree (fname);
if (!wfname)
{
@ -322,11 +322,11 @@ scan_directory (const char *dname, scanctrl_t scanctrl)
do
{
char *fname = wchar_to_utf8 (fi.cFileName);
char *fname = wchar_to_native (fi.cFileName);
if (!fname)
{
err = gpg_error_from_syserror ();
log_error ("error utf8-ing filename: %s\n", w32_strerror (-1));
log_error ("error converting filename: %s\n", w32_strerror (-1));
break;
}
for (p=fname; *p; p++)