summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2023-03-10 15:41:32 (GMT)
committerGitHub <noreply@github.com>2023-03-10 15:41:32 (GMT)
commit12226bec2588f925f4698e1130ce78e118343934 (patch)
tree3f342edb1ca9f67142f321e4dffa313a9a6715fd /Doc
parent64bde502cf89963bc7382b03ea9e1c0967d22e35 (diff)
downloadcpython-12226bec2588f925f4698e1130ce78e118343934.zip
cpython-12226bec2588f925f4698e1130ce78e118343934.tar.gz
cpython-12226bec2588f925f4698e1130ce78e118343934.tar.bz2
gh-102519: Add doc updates for os.listdrives, listvolumes and listmounts (GH-102585)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/os.rst63
1 files changed, 63 insertions, 0 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 23ce987..5b9f49b 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -2188,6 +2188,69 @@ features:
Accepts a :term:`path-like object`.
+.. function:: listdrives()
+
+ Return a list containing the names of drives on a Windows system.
+
+ A drive name typically looks like ``'C:\\'``. Not every drive name
+ will be associated with a volume, and some may be inaccessible for
+ a variety of reasons, including permissions, network connectivity
+ or missing media. This function does not test for access.
+
+ May raise :exc:`OSError` if an error occurs collecting the drive
+ names.
+
+ .. audit-event:: os.listdrives "" os.listdrives
+
+ .. availability:: Windows
+
+ .. versionadded:: 3.12
+
+
+.. function:: listmounts(volume)
+
+ Return a list containing the mount points for a volume on a Windows
+ system.
+
+ *volume* must be represented as a GUID path, like those returned by
+ :func:`os.listvolumes`. Volumes may be mounted in multiple locations
+ or not at all. In the latter case, the list will be empty. Mount
+ points that are not associated with a volume will not be returned by
+ this function.
+
+ The mount points return by this function will be absolute paths, and
+ may be longer than the drive name.
+
+ Raises :exc:`OSError` if the volume is not recognized or if an error
+ occurs collecting the paths.
+
+ .. audit-event:: os.listmounts volume os.listmounts
+
+ .. availability:: Windows
+
+ .. versionadded:: 3.12
+
+
+.. function:: listvolumes()
+
+ Return a list containing the volumes in the system.
+
+ Volumes are typically represented as a GUID path that looks like
+ ``\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\``. Files can
+ usually be accessed through a GUID path, permissions allowing.
+ However, users are generally not familiar with them, and so the
+ recommended use of this function is to retrieve mount points
+ using :func:`os.listmounts`.
+
+ May raise :exc:`OSError` if an error occurs collecting the volumes.
+
+ .. audit-event:: os.listvolumes "" os.listvolumes
+
+ .. availability:: Windows
+
+ .. versionadded:: 3.12
+
+
.. function:: lstat(path, *, dir_fd=None)
Perform the equivalent of an :c:func:`lstat` system call on the given path.