Opened 10 years ago

Last modified 10 years ago

#6884 new Feature Requests

Add functionality to enumerate filesystem roots

Reported by: Erik Jensen <Erik.Jensen@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.49.0 Severity: Not Applicable
Keywords: Cc: ulrich.eckhardt@…

Description

Unlike POSIX systems, which root everything at '/', some systems (notably Windows) provide multiple filesystem roots.

In order to abstract this difference in a cross-platform way, I propose that a new function be added to boost::filesystem to return a list of path objects, one for each filesystem root. On a POSIX system, this would simply return ["/"], but on Windows, it would return, e.g., ["C:/", "D:/"]. This would make it possible to implement something like a filesystem browser in a platform-independent manner.

There is precedence for this functionality in several cross-platform libraries, including Java (File.listRoots), Qt (QDir::drives), and Poco (Poco::Path::listRoots).

Change History (1)

comment:1 by Ulrich Eckhardt <ulrich.eckhardt@…>, 10 years ago

Cc: ulrich.eckhardt@… added

MS Windows CE also uses a single root "\", so the drive letters are only present

#if (defined(_WIN32) || defined(WIN32)) && !defined(UNDER_CE)}}}

Otherwise I agree that this would be a useful addition. OTOH, translating "/C:/" to "C:\" would also be feasible, you could then get the list of drives by listing the content of "/". I'd take it to the developers' mailinglist for discussion.

Note: See TracTickets for help on using tickets.