QDir::isWritable()?
-
@#include <QtGui/QApplication>
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
#include <QtCore/QDir>int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QFileInfo fi(QDir::homePath());
if (fi.isDir() && fi.isWritable()){
qDebug() << "voila";
}else{
qDebug() << "not so good";
}
app.exec();
}@For me this whole indeed printed "voila"
-
I tried this and it worked. I must be doing something else wrong in my original program, but I just can't figure out what!
My code is like this:
@
QFileInfo fi(QFileInfo(outputDir).path());
if (!fi.isWritable())
{
QMessageBox::warning(NULL, "Error", "You must have write permission to the output directory.", QMessageBox::Ok, NULL);
}
@On Linux it works, but on windows I get the error message every time.
-
-
Look at the documentation for path()
"http://doc.qt.nokia.com/4.6/qfileinfo.html#path":http://doc.qt.nokia.com/4.6/qfileinfo.html#path
-
I know I started this thread a long time ago, but I just stumbled over the answer while browsing the documentation for QFile. There, it says, (http://doc.qt.nokia.com/4.7/qfile.html#platform-specific-issues)
"File permissions are handled differently on Linux/Mac OS X and Windows. In a non writable directory on Linux, files cannot be created. This is not always the case on Windows, where, for instance, the 'My Documents' directory usually is not writable, but it is still possible to create files in it."
It appears that it really is not writable, but I could create files in it.