Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
how to make a folder non writable
I have a need to make a folder non writable
I have made a QFile object and set the permissions to 0 but I am still able to perform a mkpath operation
QFile file(dir.path()); QString s = file.fileName(); QFile::Permissions permissions = file.permissions(); QFile::Permissions oldPermissions = permissions; permissions &= QFile::ExeGroup; permissions &= QFile::ReadOwner; permissions &= QFile::WriteOwner; permissions &= QFile::ReadUser; permissions &= QFile::WriteUser; permissions &= QFile::ExeUser; permissions &= QFile::ReadGroup; permissions &= QFile::WriteGroup; permissions &= QFile::ReadOther; permissions &= QFile::WriteOther; permissions &= QFile::ExeOther; file.setPermissions(permissions);
What is the correct way of doing this
Are you sure QFile will do it with a folder ?
QFile::Permissions perm = QFileInfo( "c:/ACCESS_DENIED/" ).permissions();
Since it mention folder also.
Never tried it! so just suggestion.
Thanks for your reply
I dont think this will allow me to set the permissions on the folder though
Yeah, after I posted ,
I realized that QFileInfo seems to have no setPermissions so
its back to QFile again. sorry.
Its under linux I assume ?
So the user the program runs under/as do have the permission to set permissions ?
Actually this is running under Windows
Dont think I can do it using Qt tho
and you did notice
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
Well, if you trying to set the Read Only flag for the folder,
i think you are right that it wont work with Qt and you would have to resort to
If that is the effect you want to get.
Thanks for your help