Skip to content

Commit

Permalink
gh-102519: Add doc updates for os.listdrives, listvolumes and listmou…
Browse files Browse the repository at this point in the history
…nts (GH-102585)
  • Loading branch information
zooba committed Mar 10, 2023
1 parent 64bde50 commit 12226be
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 12226be

Please sign in to comment.