diff options
author | Charles Machalow <csm10495@gmail.com> | 2022-11-22 17:19:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 17:19:34 (GMT) |
commit | 1b2de89bce7eee3c63ce2286f071db57cd2cfa22 (patch) | |
tree | 34dfc872d34c8468edb2b7ef37cb89055097846e /Modules/posixmodule.c | |
parent | c2102136be569e6fc8ed90181f229b46d07142f8 (diff) | |
download | cpython-1b2de89bce7eee3c63ce2286f071db57cd2cfa22.zip cpython-1b2de89bce7eee3c63ce2286f071db57cd2cfa22.tar.gz cpython-1b2de89bce7eee3c63ce2286f071db57cd2cfa22.tar.bz2 |
gh-99547: Add isjunction methods for checking if a path is a junction (GH-99548)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 98fc264..45e71ee 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -13633,6 +13633,25 @@ os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class) #endif } +/*[clinic input] +os.DirEntry.is_junction -> bool + defining_class: defining_class + / + +Return True if the entry is a junction; cached per entry. +[clinic start generated code]*/ + +static int +os_DirEntry_is_junction_impl(DirEntry *self, PyTypeObject *defining_class) +/*[clinic end generated code: output=7061a07b0ef2cd1f input=475cd36fb7d4723f]*/ +{ +#ifdef MS_WINDOWS + return self->win32_lstat.st_reparse_tag == IO_REPARSE_TAG_MOUNT_POINT; +#else + return 0; +#endif +} + static PyObject * DirEntry_fetch_stat(PyObject *module, DirEntry *self, int follow_symlinks) { @@ -13927,6 +13946,7 @@ static PyMethodDef DirEntry_methods[] = { OS_DIRENTRY_IS_DIR_METHODDEF OS_DIRENTRY_IS_FILE_METHODDEF OS_DIRENTRY_IS_SYMLINK_METHODDEF + OS_DIRENTRY_IS_JUNCTION_METHODDEF OS_DIRENTRY_STAT_METHODDEF OS_DIRENTRY_INODE_METHODDEF OS_DIRENTRY___FSPATH___METHODDEF |