[Interest] When is QDir::Drives useful?

Nikos Chantziaras realnc at gmail.com
Tue Jul 31 08:59:47 CEST 2012


I mean QDir::Drives the enum, not QDir::drives() the function :-)


On 31/07/12 09:58, Scott Aron Bloom wrote:
> Since  Im no longer sure what this discussion is about... Back to the original question, when is QDir::drives() useful..
>
> Here is code...
> #include <QCoreApplication>
> #include <QDir>
> #include <QFileInfo>
> #include <QDebug>
> int main( int argc, char ** argv )
> {
>      QFileInfoList drives = QDir::drives();
>      foreach( const QFileInfo & curr, drives )
>      {
>          qDebug() << curr.absoluteFilePath();
>      }
> }
>
>
> Which when run as a console app returns:
> "C:/"
> "D:/"
> "E:/"
> "F:/"
> "G:/"
>
>
> This is on a Win7 machine, running Qt 4.7.4.. However this is the results I have been getting/expecting for years...
>
> So what is the issue?  Are we completely off QDir::Drives?
>
> Scott
>
> -----Original Message-----
> From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Nikos Chantziaras
> Sent: Monday, July 30, 2012 11:52 PM
> To: interest at qt-project.org
> Subject: Re: [Interest] When is QDir::Drives useful?
>
> On 31/07/12 09:33, André Somers wrote:
>> Op 31-7-2012 8:30, André Somers schreef:
>>> Op 31-7-2012 8:20, Nikos Chantziaras schreef:
>>>> Nope.  I just tested it under Windows XP and 7.  The contents of "/"
>>>> are the contents of "C:/".  Which makes sense, since Windows
>>>> completely lacks the concept of a single root directory.  So I guess
>>>> the question remains open.
>>> Who said that / is the root directory on Windows?
>>> Try "", or better yet, the result of QDir::rootPath();
>
> Just tested.  QDir::rootPath() returns "C:\".
>
>
>> BTW: note that for instance QFileSystemModel uses the same flags, and
>> also can display the windows "root" directory (or My Computer) listing
>> the drives.
>
> "My Computer" is not an existing directory though.  It's a programmatically constructed, uhm, construct.
>
> An alternative way to ask the question is: If you open a command prompt (cmd.exe), where would you have to "cd" into so that "dir" would list drives?





More information about the Interest mailing list