* fhandler_registry.cc (multi_wcstombs): New function.
(fhandler_registry::fstat): Call multi_wcstombs for strings of type REG_MULTI_SZ. (fhandler_registry::fill_filebuf): Ditto.
This commit is contained in:
parent
fca8f35f11
commit
88addc6476
@ -1,3 +1,10 @@
|
|||||||
|
2010-05-26 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* fhandler_registry.cc (multi_wcstombs): New function.
|
||||||
|
(fhandler_registry::fstat): Call multi_wcstombs for strings of type
|
||||||
|
REG_MULTI_SZ.
|
||||||
|
(fhandler_registry::fill_filebuf): Ditto.
|
||||||
|
|
||||||
2010-05-26 Christopher Faylor <me+cygwin@cgf.cx>
|
2010-05-26 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
* hires.h (hires_base::reset): New function.
|
* hires.h (hires_base::reset): New function.
|
||||||
|
@ -230,6 +230,37 @@ key_exists (HKEY parent, const wchar_t *name, DWORD wow64)
|
|||||||
return (error == ERROR_SUCCESS || error == ERROR_ACCESS_DENIED);
|
return (error == ERROR_SUCCESS || error == ERROR_ACCESS_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
multi_wcstombs (char *dst, size_t len, const wchar_t *src, size_t nwc)
|
||||||
|
{
|
||||||
|
size_t siz, sum = 0;
|
||||||
|
const wchar_t *nsrc;
|
||||||
|
|
||||||
|
while (nwc)
|
||||||
|
{
|
||||||
|
siz = sys_wcstombs (dst, len, src, nwc);
|
||||||
|
sum += siz;
|
||||||
|
if (dst)
|
||||||
|
{
|
||||||
|
dst += siz;
|
||||||
|
len -= siz;
|
||||||
|
}
|
||||||
|
nsrc = wcschr (src, L'\0') + 1;
|
||||||
|
if ((size_t) (nsrc - src) >= nwc)
|
||||||
|
break;
|
||||||
|
nwc -= nsrc - src;
|
||||||
|
src = nsrc;
|
||||||
|
if (*src == L'\0')
|
||||||
|
{
|
||||||
|
if (dst)
|
||||||
|
*dst++ = '\0';
|
||||||
|
++sum;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns 0 if path doesn't exist, >0 if path is a directory,
|
/* Returns 0 if path doesn't exist, >0 if path is a directory,
|
||||||
* <0 if path is a file.
|
* <0 if path is a file.
|
||||||
*
|
*
|
||||||
@ -456,11 +487,16 @@ fhandler_registry::fstat (struct __stat64 *buf)
|
|||||||
NULL, NULL, tmpbuf, &dwSize)
|
NULL, NULL, tmpbuf, &dwSize)
|
||||||
!= ERROR_SUCCESS)
|
!= ERROR_SUCCESS)
|
||||||
buf->st_size = dwSize / sizeof (wchar_t);
|
buf->st_size = dwSize / sizeof (wchar_t);
|
||||||
|
else if (type == REG_MULTI_SZ)
|
||||||
|
buf->st_size = multi_wcstombs (NULL, 0,
|
||||||
|
(wchar_t *) tmpbuf,
|
||||||
|
dwSize / sizeof (wchar_t));
|
||||||
else
|
else
|
||||||
buf->st_size = sys_wcstombs (NULL, 0,
|
buf->st_size = sys_wcstombs (NULL, 0,
|
||||||
(wchar_t *) tmpbuf,
|
(wchar_t *) tmpbuf,
|
||||||
dwSize / sizeof (wchar_t));
|
dwSize / sizeof (wchar_t));
|
||||||
free (tmpbuf);
|
if (tmpbuf)
|
||||||
|
free (tmpbuf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
buf->st_size = dwSize;
|
buf->st_size = dwSize;
|
||||||
@ -848,17 +884,21 @@ fhandler_registry::fill_filebuf ()
|
|||||||
seterrno_from_win_error (__FILE__, __LINE__, error);
|
seterrno_from_win_error (__FILE__, __LINE__, error);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_MULTI_SZ
|
if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_LINK)
|
||||||
|| type == REG_LINK)
|
|
||||||
bufalloc = sys_wcstombs (NULL, 0, (wchar_t *) tmpbuf,
|
bufalloc = sys_wcstombs (NULL, 0, (wchar_t *) tmpbuf,
|
||||||
size / sizeof (wchar_t));
|
size / sizeof (wchar_t));
|
||||||
|
else if (type == REG_MULTI_SZ)
|
||||||
|
bufalloc = multi_wcstombs (NULL, 0, (wchar_t *) tmpbuf,
|
||||||
|
size / sizeof (wchar_t));
|
||||||
else
|
else
|
||||||
bufalloc = size;
|
bufalloc = size;
|
||||||
filebuf = (char *) cmalloc_abort (HEAP_BUF, bufalloc);
|
filebuf = (char *) cmalloc_abort (HEAP_BUF, bufalloc);
|
||||||
if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_MULTI_SZ
|
if (type == REG_SZ || type == REG_EXPAND_SZ || type == REG_LINK)
|
||||||
|| type == REG_LINK)
|
|
||||||
sys_wcstombs (filebuf, bufalloc, (wchar_t *) tmpbuf,
|
sys_wcstombs (filebuf, bufalloc, (wchar_t *) tmpbuf,
|
||||||
size / sizeof (wchar_t));
|
size / sizeof (wchar_t));
|
||||||
|
else if (type == REG_MULTI_SZ)
|
||||||
|
multi_wcstombs (filebuf, bufalloc, (wchar_t *) tmpbuf,
|
||||||
|
size / sizeof (wchar_t));
|
||||||
else
|
else
|
||||||
memcpy (filebuf, tmpbuf, bufalloc);
|
memcpy (filebuf, tmpbuf, bufalloc);
|
||||||
filesize = bufalloc;
|
filesize = bufalloc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user