Create _Py_wchar2char() function, reverse of _Py_char2wchar()

* Use _Py_wchar2char() in _wstat() and _Py_wfopen()
 * Document _Py_char2wchar()
This commit is contained in:
Victor Stinner 2010-08-13 23:29:08 +00:00
parent e9b428f997
commit f2e08b34f1
3 changed files with 97 additions and 11 deletions

View file

@ -139,13 +139,16 @@ static wchar_t *lib_python = L"lib/python" VERSION;
static int
_wstat(const wchar_t* path, struct stat *buf)
{
char fname[PATH_MAX];
size_t res = wcstombs(fname, path, sizeof(fname));
if (res == (size_t)-1) {
int err;
char *fname;
fname = _Py_wchar2char(path);
if (fname == NULL) {
errno = EINVAL;
return -1;
}
return stat(fname, buf);
err = stat(fname, buf);
PyMem_Free(fname);
return err;
}
#endif