c++qtqdir

Find out if file path is mapped / remote or local


Is it possible to find out if a drive path (e.g. P:/temp/foo) is local or remote?

Here ( CMD line to tell if a file/path is local or remote? ) it's shown for a cmd evaluation, but I am looking for a C++/Qt way.

Related to:

  1. QDir::exists with mapped remote directory
  2. How to perform Cross-Platform Asynchronous File I/O in C++

Solution

  • There's no way in Qt, at least up to Qt 5.5. QStorageInfo would be the closest fit, but there is no agreement about how such an API should look like (see the gigantic discussion that started in this thread; basically one risks to have Qt reporting misleading information).

    So, for now, you're up to using native APIs. The aforementioned GetDriveType would be fine for Windows, but you're pretty much on your own on Linux and Mac.