QNtfsPermissionCheckGuard Class

The QNtfsPermissionCheckGuard class is a RAII class to manage NTFS permission checking. 更多...

头: #include <QNtfsPermissionCheckGuard>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.6

公共函数

QNtfsPermissionCheckGuard ()
~QNtfsPermissionCheckGuard ()
(从 6.6 起) bool qAreNtfsPermissionChecksEnabled ()
(从 6.6 起) bool qDisableNtfsPermissionChecks ()
(从 6.6 起) bool qEnableNtfsPermissionChecks ()

详细描述

For performance reasons, QFile , QFileInfo , and related classes do not perform full ownership and permission (ACL) checking on NTFS file systems by default. During the lifetime of any instance of this class, that default is overridden and advanced checking is performed. This provides a safe and easy way to manage enabling and disabling this change to the default behavior.

范例:

void complexFunction()
{
    QNtfsPermissionCheckGuard permissionGuard;  // check is enabled
    // do complex things here that need permission check enabled
}   // as the guard goes out of scope the check is disabled
					

This class is available only on Windows.

qt_ntfs_permission_lookup

Prior to Qt 6.6, the user had to directly manipulate the global variable qt_ntfs_permission_lookup . However, this was a non-atomic global variable and as such it was prone to data races.

The variable qt_ntfs_permission_lookup is therefore deprecated since Qt 6.6.

成员函数文档编制

QNtfsPermissionCheckGuard:: QNtfsPermissionCheckGuard ()

Creates a guard and calls the function qEnableNtfsPermissionChecks ().

[noexcept] QNtfsPermissionCheckGuard:: ~QNtfsPermissionCheckGuard ()

Destroys the guard and calls the function qDisableNtfsPermissionChecks ().

相关非成员

[noexcept, since 6.6] bool qAreNtfsPermissionChecksEnabled ()

Checks the status of the permission checks on NTFS file systems. Returns true if the check is enabled.

This function is only available on Windows and makes the direct manipulation of qt_ntfs_permission_lookup obsolete.

注意: The thread-safety of this function holds only as long as there are no concurrent updates to qt_ntfs_permission_lookup .

注意: 此函数是 thread-safe .

该函数在 Qt 6.6 引入。

[noexcept, since 6.6] bool qDisableNtfsPermissionChecks ()

Disables permission checking on NTFS file systems. Returns true if the check is disabled, meaning that there are no more users.

This function is only available on Windows and makes the direct manipulation of qt_ntfs_permission_lookup obsolete.

This is a low-level function and must (only) be called to match one earlier call to qEnableNtfsPermissionChecks (). Please consider the RAII class QNtfsPermissionCheckGuard 代替。

注意: The thread-safety of this function holds only as long as there are no concurrent updates to qt_ntfs_permission_lookup .

注意: 此函数是 thread-safe .

该函数在 Qt 6.6 引入。

[noexcept, since 6.6] bool qEnableNtfsPermissionChecks ()

Enables permission checking on NTFS file systems. Returns true if the check was already enabled before the call to this function, meaning that there are other users.

This function is only available on Windows and makes the direct manipulation of qt_ntfs_permission_lookup obsolete.

This is a low-level function, please consider the RAII class QNtfsPermissionCheckGuard 代替。

注意: The thread-safety of this function holds only as long as there are no concurrent updates to qt_ntfs_permission_lookup .

注意: 此函数是 thread-safe .

该函数在 Qt 6.6 引入。