Qt setPermissions does not set permissions

I am not sure why, but my code below does not set permissions for the file. Not sure what might be wrong with the code.

SYSTEM: Windows XP Pro SP2. Run in administrator account as administrator. New frames and Qt 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;

The return value of TRUE ... claims to have set permissions, but it is not. To be clear, file2.txt is a copy of file1.txt. I set permissions file1 as something, but file2.txt has different permissions after running my code.

+3
source share
2 answers

QT . , .

MSDN :

, GetNamedSecurityInfo GetSecurityInfo. , SetNamedSecurityInfo SetSecurityInfo.

, GetNamedSecurityInfo SetNamedSecurityInfo .


NULL ACL reset :

SetNamedSecurityInfoA("C:\file.txt", SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL);
+2

WinXP Pro SP2, , NTFS.

Qt:

, Qt NTFS , . NTFS :

extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;

qt_ntfs_permission_lookup 1.

qt_ntfs_permission_lookup++; // turn checking on
qt_ntfs_permission_lookup--; // turn it off again
0

Source: https://habr.com/ru/post/1792630/


All Articles