Qt5: QDir::mkpath() fails for /cygdrive/ paths

David Stacey drstacey@tiscali.co.uk
Thu Jul 9 19:15:00 GMT 2015


QDir::mkpath() fails when creating paths that start '/cygdrive/'. This 
problem is only shown with Qt5 (not Qt4), and only with paths that start 
'/cygdrive/' (so running from my home directory '~' is fine). This is 
not a permissions problem, as it works fine with Qt4.

Sample programme is below. Compile for Qt5 as per the comments. 'cd 
/cygdrive/X' where X is a local drive where you have permissions to 
create a directory. Run './create_directory new_dir' and it fails to 
create the directory. Programme works fine when compiled with Qt4.

I am using libQt5Core5-5.4.1-4 and libQt4-4.8.7-1 under cygwin-2.0.4-1. 
I haven't had chance to try with Qt 5.4.2 (announced yesterday), so 
apologies in advance if this is fixed already.

Dave.


// Programme to create a directory.
// Works with Qt4:
// g++ -I/usr/include/qt4 -o create_directory create_directory.cpp -lQtCore
//
// Fails with Qt5 if run from a path starting '/cygdrive/', otherwise OK:
// g++ -I/usr/include/qt5 -o create_directory create_directory.cpp -lQt5Core

#include <QtCore/QDir>
#include <iostream>

int main(int argc, char** argv)
{
   if (argc != 2)
     std::cerr << "Syntax: create_directory <name>";
   else
   {
     QDir dir(QDir::currentPath());
     if (!dir.mkpath(argv[1]))
       std::cerr << "Failed to create directory '"
                 << argv[1] << "'." << std::endl;
   }
   return 0;
}




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list