- Qt 6.8
- Qt Core
- C++ Classes
- QNtfsPermissionCheckGuard
- Qt 6.8.3 Reference Documentation

# QNtfsPermissionCheckGuard Class

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

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

- List of all members, including inherited members
- QNtfsPermissionCheckGuard is part of Input/Output and Networking.

## Public Functions

| QNtfsPermissionCheckGuard()
| ~QNtfsPermissionCheckGuard()

## Related Non-Members

`(since 6.6)` bool | qAreNtfsPermissionChecksEnabled()
`(since 6.6)` bool | qDisableNtfsPermissionChecks()
`(since 6.6)` bool | qEnableNtfsPermissionChecks()

## Detailed Description

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.

Example:

     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.

## Member Function Documentation

### QNtfsPermissionCheckGuard::QNtfsPermissionCheckGuard()

Creates a guard and calls the function qEnableNtfsPermissionChecks().

### `[noexcept]` QNtfsPermissionCheckGuard::~QNtfsPermissionCheckGuard()

Destroys the guard and calls the function qDisableNtfsPermissionChecks().

## Related Non-Members

### `[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.

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

Note: This function is thread-safe.

This function was introduced in 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 instead.

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

Note: This function is thread-safe.

This function was introduced in 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 instead.

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

Note: This function is thread-safe.

This function was introduced in Qt 6.6.