Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12226be

Browse files
authored
gh-102519: Add doc updates for os.listdrives, listvolumes and listmounts (GH-102585)
1 parent 64bde50 commit 12226be

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Doc/library/os.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,69 @@ features:
21882188
Accepts a :term:`path-like object`.
21892189

21902190

2191+
.. function:: listdrives()
2192+
2193+
Return a list containing the names of drives on a Windows system.
2194+
2195+
A drive name typically looks like ``'C:\\'``. Not every drive name
2196+
will be associated with a volume, and some may be inaccessible for
2197+
a variety of reasons, including permissions, network connectivity
2198+
or missing media. This function does not test for access.
2199+
2200+
May raise :exc:`OSError` if an error occurs collecting the drive
2201+
names.
2202+
2203+
.. audit-event:: os.listdrives "" os.listdrives
2204+
2205+
.. availability:: Windows
2206+
2207+
.. versionadded:: 3.12
2208+
2209+
2210+
.. function:: listmounts(volume)
2211+
2212+
Return a list containing the mount points for a volume on a Windows
2213+
system.
2214+
2215+
*volume* must be represented as a GUID path, like those returned by
2216+
:func:`os.listvolumes`. Volumes may be mounted in multiple locations
2217+
or not at all. In the latter case, the list will be empty. Mount
2218+
points that are not associated with a volume will not be returned by
2219+
this function.
2220+
2221+
The mount points return by this function will be absolute paths, and
2222+
may be longer than the drive name.
2223+
2224+
Raises :exc:`OSError` if the volume is not recognized or if an error
2225+
occurs collecting the paths.
2226+
2227+
.. audit-event:: os.listmounts volume os.listmounts
2228+
2229+
.. availability:: Windows
2230+
2231+
.. versionadded:: 3.12
2232+
2233+
2234+
.. function:: listvolumes()
2235+
2236+
Return a list containing the volumes in the system.
2237+
2238+
Volumes are typically represented as a GUID path that looks like
2239+
``\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\``. Files can
2240+
usually be accessed through a GUID path, permissions allowing.
2241+
However, users are generally not familiar with them, and so the
2242+
recommended use of this function is to retrieve mount points
2243+
using :func:`os.listmounts`.
2244+
2245+
May raise :exc:`OSError` if an error occurs collecting the volumes.
2246+
2247+
.. audit-event:: os.listvolumes "" os.listvolumes
2248+
2249+
.. availability:: Windows
2250+
2251+
.. versionadded:: 3.12
2252+
2253+
21912254
.. function:: lstat(path, *, dir_fd=None)
21922255

21932256
Perform the equivalent of an :c:func:`lstat` system call on the given path.

0 commit comments

Comments
 (0)