mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
Merge
This commit is contained in:
parent
ce5493f33d
commit
caea7e8d23
3 changed files with 51 additions and 0 deletions
|
@ -4199,6 +4199,41 @@ win32_kill(PyObject *self, PyObject *args)
|
|||
CloseHandle(handle);
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
posix__isdir(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *opath;
|
||||
char *path;
|
||||
PyUnicodeObject *po;
|
||||
DWORD attributes;
|
||||
|
||||
if (PyArg_ParseTuple(args, "U|:_isdir", &po)) {
|
||||
Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
|
||||
|
||||
attributes = GetFileAttributesW(wpath);
|
||||
if (attributes == INVALID_FILE_ATTRIBUTES)
|
||||
Py_RETURN_FALSE;
|
||||
goto check;
|
||||
}
|
||||
/* Drop the argument parsing error as narrow strings
|
||||
are also valid. */
|
||||
PyErr_Clear();
|
||||
|
||||
if (!PyArg_ParseTuple(args, "et:_isdir",
|
||||
Py_FileSystemDefaultEncoding, &path))
|
||||
return NULL;
|
||||
|
||||
attributes = GetFileAttributesA(path);
|
||||
if (attributes == INVALID_FILE_ATTRIBUTES)
|
||||
Py_RETURN_FALSE;
|
||||
|
||||
check:
|
||||
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
#ifdef HAVE_PLOCK
|
||||
|
@ -8968,6 +9003,7 @@ static PyMethodDef posix_methods[] = {
|
|||
{"abort", posix_abort, METH_NOARGS, posix_abort__doc__},
|
||||
#ifdef MS_WINDOWS
|
||||
{"_getfullpathname", posix__getfullpathname, METH_VARARGS, NULL},
|
||||
{"_isdir", posix__isdir, METH_VARARGS, NULL},
|
||||
#endif
|
||||
#ifdef HAVE_GETLOADAVG
|
||||
{"getloadavg", posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue