[Source Code]


#include <QDir>
#include <QDebug>

void static_test()
{
  qDebug() << "separator   =" << QDir::separator();
  qDebug() << "currentPath =" << QDir::currentPath();
  qDebug() << "homePath    =" << QDir::homePath();
  qDebug() << "rootPath    =" << QDir::rootPath();
  qDebug() << "tempPath    =" << QDir::tempPath();
}

void dir_test(QString _dir)
{
  QDir dir(_dir);

  qDebug() << "path             =" << dir.path();
  qDebug() << "absolutePath     =" << dir.absolutePath();
  qDebug() << "canonicalPath    =" << dir.canonicalPath();
  qDebug() << "dirName          =" << dir.dirName();
  qDebug() << "isReadable       =" << dir.isReadable();
  qDebug() << "exists           =" << dir.exists();
  qDebug() << "isRoot           =" << dir.isRoot();
  qDebug() << "isRelative       =" << dir.isRelative();
  qDebug() << "isAbsolute       =" << dir.isAbsolute();
}

int main(int argc, char* argv[])
{
  if (argc == 1)
  {
    static_test();
  } else
  {
    for (int i = 1; i < argc; i++)
    {
      dir_test(argv[i]);
    }
  }
}



[Result]


D:\Temp\qt\qdir_test>qdir_test

separator   = '\'

currentPath = "D:/Temp/qt/qdir_test"

homePath    = "C:/Users/unknown"

rootPath    = "C:/"

tempPath    = "C:/Users/unknown/AppData/Local/Temp"


D:\Temp\qt\qdir_test>qdir_test c:\windows\system32

path             = "c:/windows/system32"

absolutePath     = "c:/windows/system32"

canonicalPath    = "C:/windows/system32"

dirName          = "system32"

isReadable       = true

exists           = true

isRoot           = false

isRelative       = false

isAbsolute       = true


D:\Temp\qt\qdir_test>qdir_test /usr/local/lib

path             = "/usr/local/lib"

absolutePath     = "/usr/local/lib"

canonicalPath    = ""

dirName          = "lib"

isReadable       = false

exists           = false

isRoot           = false

isRelative       = false

isAbsolute       = true