branch merge?

This commit is contained in:
Brian Curtin 2011-06-13 16:10:32 -05:00
commit a87d586fd6
27 changed files with 302 additions and 79 deletions

View file

@ -2866,6 +2866,45 @@ posix__getfileinformation(PyObject *self, PyObject *args)
info.nFileIndexHigh,
info.nFileIndexLow);
}
PyDoc_STRVAR(posix__isdir__doc__,
"Return true if the pathname refers to an existing directory.");
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, "O&:_isdir",
PyUnicode_FSConverter, &opath))
return NULL;
path = PyBytes_AsString(opath);
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 */
PyDoc_STRVAR(posix_mkdir__doc__,
@ -8102,6 +8141,7 @@ static PyMethodDef posix_methods[] = {
{"_getfullpathname", posix__getfullpathname, METH_VARARGS, NULL},
{"_getfinalpathname", posix__getfinalpathname, METH_VARARGS, NULL},
{"_getfileinformation", posix__getfileinformation, METH_VARARGS, NULL},
{"_isdir", posix__isdir, METH_VARARGS, posix__isdir__doc__},
#endif
#ifdef HAVE_GETLOADAVG
{"getloadavg", posix_getloadavg, METH_NOARGS, posix_getloadavg__doc__},