Skip to content

Fixup #14021 (Add file mode specifier to PathMatch)#7689

Merged
danmar merged 1 commit intocppcheck-opensource:mainfrom
glankk:pathmatch_filemode
Jul 31, 2025
Merged

Fixup #14021 (Add file mode specifier to PathMatch)#7689
danmar merged 1 commit intocppcheck-opensource:mainfrom
glankk:pathmatch_filemode

Conversation

@glankk
Copy link
Copy Markdown
Collaborator

@glankk glankk commented Jul 20, 2025

This is an addendum to #7645 that adds the ability to specify directory-only matching in PathMatch patterns with a trailing slash. I originally didn't add this because I wanted to keep PathMatch purely syntactic, and this feature seemed like it would require filesystem calls in the PathMatch code.

This PR solves that problem by lifting the responsibility of file mode checking to the caller, thus keeping PathMatch purely syntactic while still supporting directory-only matching.

Previously /test/foo/ would match /test/foo even if foo is a regular file. With this change the caller can specify the file mode of the file named by the provided path, and /test/foo will only match when the file mode is directory.

The semantics of patterns that do not have a trailing slash is unchanged, e.g. /test/foo still matches /test/foo/ and /test/foo/bar.cpp, regardless of the file mode.

Also adds some more tests.

@sonarqubecloud
Copy link
Copy Markdown

@glankk glankk changed the title Add file mode specifier to PathMatch Fixup #14021 (Add file mode specifier to PathMatch) Jul 21, 2025
@glankk glankk marked this pull request as ready for review July 21, 2025 17:49
Copy link
Copy Markdown
Collaborator

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to tweak the manual a bit?

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jul 31, 2025

I merge this with the assumption that the manual will be updated soonish..

@danmar danmar merged commit b78a8c0 into cppcheck-opensource:main Jul 31, 2025
65 checks passed
@glankk glankk deleted the pathmatch_filemode branch August 15, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants