Skip to content

Add os.listdrives on Windows #102519

Description

@zooba

We don't currently have a way to get all the root directories on Windows, since os.listdir('/') doesn't contain everything.

I propose a very simple API:

>>> os.listdrives()
["C:\\", "D:\\", ...]
>>> os.listdrives(uuids=True)
["\\?\Volume{4c1b02c1-d990-11dc-99ae-806e6f6e6963}\", ...]

Basically, listdrives(uuids=True) would return everything found by FindNextVolume, while listdrives() would apply GetVolumePathNamesForVolumeName to each GUID and return all of those. (This may return the same volume multiple times under different names, which is fine - os.stat can be used to see if they're the same st_dev.)

There's an endless amount of variations we could also apply here, but the most important functionality in my mind is to expose the OS API. App developers at least then have a starting point to do whatever they may need.

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions