Dela via


CFileFind::MatchesMask

Call this member function to test the file attributes on the found file.

virtual BOOL MatchesMask(
   DWORD dwMask 
) const;

Parameters

  • dwMask
    Specifies one or more file attributes, identified in the WIN32_FIND_DATA structure, for the found file. To search for multiple attributes, use the bitwise OR (|) operator. Any combination of the following attributes is acceptable:

    • FILE_ATTRIBUTE_ARCHIVE   The file is an archive file. Applications use this attribute to mark files for backup or removal.

    • FILE_ATTRIBUTE_COMPRESSED   The file or directory is compressed. For a file, this means that all of the data in the file is compressed. For a directory, this means that compression is the default for newly created files and subdirectories.

    • FILE_ATTRIBUTE_DIRECTORY   The file is a directory.

    • FILE_ATTRIBUTE_NORMAL   The file has no other attributes set. This attribute is valid only if used alone. All other file attributes override this attribute.

    • FILE_ATTRIBUTE_HIDDEN   The file is hidden. It is not to be included in an ordinary directory listing.

    • FILE_ATTRIBUTE_READONLY   The file is read only. Applications can read the file but cannot write to it or delete it.

    • FILE_ATTRIBUTE_SYSTEM   The file is part of or is used exclusively by the operating system.

    • FILE_ATTRIBUTE_TEMPORARY   The file is being used for temporary storage. Applications should write to the file only if absolutely necessary. Most of the file's data remains in memory without being flushed to the media because the file will soon be deleted.

Return Value

Nonzero if successful; otherwise 0. To get extended error information, call the Win32 function GetLastError.

Remarks

You must call FindNextFile at least once before calling MatchesMask.

Example

// This code fragment shows all of the files in the root directory
// of drive C: which have either the hidden attribute or the system
// attribute, or both.

CFileFind finder;

BOOL bWorking = finder.FindFile(_T("C:\\*.*"));

while (bWorking)
{
   bWorking = finder.FindNextFile();

   if (finder.MatchesMask(FILE_ATTRIBUTE_HIDDEN | 
      FILE_ATTRIBUTE_SYSTEM))
   {
      _tprintf_s(_T("%s\n"), (LPCTSTR) finder.GetFileName());
   }
}

Requirements

Header: afx.h

See Also

Reference

CFileFind Class

Hierarchy Chart

CFileFind::IsDots

CFileFind::IsReadOnly

CFileFind::IsDirectory

CFileFind::IsCompressed

CFileFind::IsSystem

CFileFind::IsHidden

CFileFind::IsTemporary

CFileFind::IsNormal

CFileFind::IsArchived

Other Resources

CFileFind Members