WdDeleteSearchOptions

Specifies file and directory filter patterns for a delete operation.

Introduced in: RIT 0.0.13-preview.

Syntax

struct WdDeleteSearchOptions
{
    const char* includeFilePattern;
    const char* excludeFilePattern;
    const char* excludeDirPattern;
    uint64_t includeFileAttributes;
    uint64_t excludeFileAttributes;
    uint64_t includeDirAttributes;
    uint64_t excludeDirAttributes;
};

Members

includeFilePattern
Type: const char*

Includes files that match the specified names. The wildcard characters * and ? are supported, and a list of patterns can be separated by a semicolon (;). The default is nullptr, which includes everything.

excludeFilePattern
Type: const char*

Excludes files that match the specified names. The wildcard characters * and ? are supported, and a list of patterns can be separated by a semicolon (;). The default is nullptr, which excludes no files.

excludeDirPattern
Type: const char*

Excludes directories that match the specified names, not paths. The wildcard characters * and ? are supported. The default is nullptr, which excludes no directories from being deleted.

includeFileAttributes
Type: uint64_t

Includes files for which any of the specified file attributes are set. The supported values are FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_SYSTEM, and FILE_ATTRIBUTE_HIDDEN. The default is 0, which includes all attributes. For additional information on file attributes check File Attribute Constants.

excludeFileAttributes
Type: uint64_t

Excludes files for which any of the specified file attributes are set. The supported values are FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_SYSTEM, and FILE_ATTRIBUTE_HIDDEN. The default is 0, which excludes no attributes. For additional information on file attributes check File Attribute Constants.

includeDirAttributes
Type: uint64_t

Includes directories for which any of the specified file attributes are set. The supported values are FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_SYSTEM, and FILE_ATTRIBUTE_HIDDEN. The default is 0, which includes all attributes.

excludeDirAttributes
Type: uint64_t

Excludes directories for which any of the specified file attributes are set. The supported values are FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_SYSTEM, and FILE_ATTRIBUTE_HIDDEN. The default is 0, which excludes no attributes.

Examples

Delete only .pdb and .log files:

WdDeleteSearchOptions searchOptions = {
    .includeFilePattern = "*.pdb;*.log",
    .excludeFilePattern = nullptr,
    .excludeDirPattern = nullptr,
    .includeFileAttributes = 0,
    .excludeFileAttributes = 0,
    .includeDirAttributes = 0,
    .excludeDirAttributes = 0
};

Delete everything except a save data directory:

WdDeleteSearchOptions searchOptions = {
    .includeFilePattern = nullptr,
    .excludeFilePattern = nullptr,
    .excludeDirPattern = "SaveData",
    .includeFileAttributes = 0,
    .excludeFileAttributes = 0,
    .includeDirAttributes = 0,
    .excludeDirAttributes = 0
};

Delete archived files, but preserve read-only files and hidden directories:

WdDeleteSearchOptions searchOptions = {
    .includeFilePattern = nullptr,
    .excludeFilePattern = nullptr,
    .excludeDirPattern = nullptr,
    .includeFileAttributes = FILE_ATTRIBUTE_ARCHIVE,
    .excludeFileAttributes = FILE_ATTRIBUTE_READONLY,
    .includeDirAttributes = 0,
    .excludeDirAttributes = FILE_ATTRIBUTE_HIDDEN
};

Note

When there is a conflict between include and exclude patterns, the exclude pattern takes precedence and the item will not be deleted.

Remarks

Pass this structure to WdDeleteRemoteFiles via the searchOptions parameter to filter which files and directories are selected for deletion. If nullptr is passed for searchOptions, all items are included with no filtering.

These options apply only when remoteFolderPath resolves to a folder. They are ignored when remoteFolderPath resolves to a single file.

A filtered delete that leaves items behind preserves the root folder even when deleteRootFolder is set to true in WdDeleteOptions, because the folder is removed only if it is left empty.

Requirements

Requirement Value
Header WdRemoteIteration.h
Library wdremoteapi.lib
Supported OS Windows 11 and later
Supported architectures x64, ARM64

See also