mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Create _Py_wchar2char() function, reverse of _Py_char2wchar()
* Use _Py_wchar2char() in _wstat() and _Py_wfopen() * Document _Py_char2wchar()
This commit is contained in:
parent
e9b428f997
commit
f2e08b34f1
3 changed files with 97 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue