I’m not sure why but my code bellow does not set permissions for a file.
Not sure what could be wrong with the code.
SYSTEM:
Windows XP Pro SP2.
Running in Admin account as admin.
Newest Qt framework and files.
//Get file permissions of ref file.
QFile::Permissions qpPerm1;
qpPerm1 = QFile::permissions("E:/dir1/dir2/File1.txt");
//Set file permissions of a file.
bool isOK=0;
isOK = QFile::setPermissions("E:/dir4/dir5/file2.txt",qpPerm1);
qout << "Perms set? " << isOK << endl;
Return value is TRUE… claims it set the permissions but it did not.
To be clear, file2.txt is a copy of file1.txt.
I set permisions of file1 to be something but file2.txt has different permissions after I run my code.
As it was written QT doesn’t support changing access rights for groups on windows. For full control over file permissions try using Access Control List which is located in security descriptor.
MSDN suggests this:
I think in your case you could try GetNamedSecurityInfo from the first file and pass it to SetNamedSecurityInfo for the second one.
Also you can assign NULL ACL and it will reset all group permissions and grant full access for everyone: