Как это не работает
C++ (Qt)
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
qt_ntfs_permission_lookup++;
QFile::Permissions perm = QFileInfo( "c:/System Volume Information" ).permissions();
bool
b = perm & QFile::ReadOwner;
qWarning() << b; // false
b = perm & QFile::WriteOwner;
qWarning() << b; // false
b = perm & QFile::ExeOwner;
qWarning() << b; // true
b = perm & QFile::ReadUser;
qWarning() << b; // false
b = perm & QFile::WriteUser;
qWarning() << b; // false
b = perm & QFile::ExeUser;
qWarning() << b; //true
b = perm & QFile::ReadGroup;
qWarning() << b; // true
b = perm & QFile::WriteGroup;
qWarning() << b; // true
b = perm & QFile::ExeGroup;
qWarning() << b; // true
b = perm & QFile::ReadOther;
qWarning() << b; // false
b = perm & QFile::WriteOther;
qWarning() << b; // false
b = perm & QFile::ExeOther;
qWarning() << b;// true
Warning: Because of differences in the platforms supported by Qt, the semantics of ReadUser, WriteUser and ExeUser are platform-dependent: On Unix, the rights of the owner of the file are returned and on Windows the rights of the current user are returned. This behavior might change in a future Qt version.
Note that Qt does not by default check for permissions on NTFS file systems, as this may decrease the performance of file handling considerably. It is possible to force permission checking on NTFS by including the following code in your source:
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
Permission checking is then turned on and off by incrementing and decrementing qt_ntfs_permission_lookup by 1.
qt_ntfs_permission_lookup++; // turn checking on
qt_ntfs_permission_lookup--; // turn it off again
The Permissions type is a typedef for QFlags<Permission>. It stores an OR combination of Permission values.