API to query filesystem type on windows

This commit is contained in:
Kovid Goyal 2022-07-14 08:54:15 +05:30
parent 9a866f197b
commit 0e044aa866
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -527,6 +527,16 @@ supports_hardlinks(PyObject *self, PyObject *args) {
Py_RETURN_FALSE; Py_RETURN_FALSE;
} }
static PyObject*
filesystem_type_name(PyObject *self, PyObject *args) {
wchar_raii path;
if (!PyArg_ParseTuple(args, "O&", py_to_wchar_no_none, &path)) return NULL;
DWORD max_component_length, flags;
wchar_t fsname[128];
if (!GetVolumeInformationW(path.ptr(), NULL, 0, NULL, &max_component_length, &flags, fsname, sizeof(fsname)/sizeof(fsname[0]))) return PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, 0, PyTuple_GET_ITEM(args, 0));
return PyUnicode_FromWideChar(fsname, -1);
}
static PyObject* static PyObject*
winutil_create_hard_link(PyObject *self, PyObject *args) { winutil_create_hard_link(PyObject *self, PyObject *args) {
wchar_raii path, existing_path; wchar_raii path, existing_path;
@ -1134,6 +1144,7 @@ static PyMethodDef winutil_methods[] = {
M(get_dll_directory, METH_NOARGS), M(get_dll_directory, METH_NOARGS),
M(create_mutex, METH_VARARGS), M(create_mutex, METH_VARARGS),
M(supports_hardlinks, METH_VARARGS), M(supports_hardlinks, METH_VARARGS),
M(filesystem_type_name, METH_VARARGS),
M(get_async_key_state, METH_VARARGS), M(get_async_key_state, METH_VARARGS),
M(create_named_pipe, METH_VARARGS), M(create_named_pipe, METH_VARARGS),
M(connect_named_pipe, METH_VARARGS), M(connect_named_pipe, METH_VARARGS),