FreeRDP
pattern.c File Reference
#include <winpr/config.h>
#include <winpr/crt.h>
#include <winpr/handle.h>
#include <winpr/file.h>
#include "../log.h"

Macros

#define TAG   WINPR_TAG("file")
 

Functions

LPSTR FilePatternFindNextWildcardA (LPCSTR lpPattern, DWORD *pFlags)
 
static BOOL FilePatternMatchSubExpressionA (LPCSTR lpFileName, size_t cchFileName, LPCSTR lpX, size_t cchX, LPCSTR lpY, size_t cchY, LPCSTR lpWildcard, LPCSTR *ppMatchEnd)
 
BOOL FilePatternMatchA (LPCSTR lpFileName, LPCSTR lpPattern)
 

Macro Definition Documentation

◆ TAG

#define TAG   WINPR_TAG("file")

WinPR: Windows Portable Runtime File Functions

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ FilePatternFindNextWildcardA()

LPSTR FilePatternFindNextWildcardA ( LPCSTR  lpPattern,
DWORD *  pFlags 
)

File System Behavior in the Microsoft Windows Environment: http://download.microsoft.com/download/4/3/8/43889780-8d45-4b2e-9d3a-c696a890309f/File%20System%20Behavior%20Overview.pdf

Here is the caller graph for this function:

◆ FilePatternMatchA()

BOOL FilePatternMatchA ( LPCSTR  lpFileName,
LPCSTR  lpPattern 
)

Wild Card Matching

'*' matches 0 or more characters '?' matches exactly one character

'~*' DOS_STAR - matches 0 or more characters until encountering and matching final '.'

'~?' DOS_QM - matches any single character, or upon encountering a period or end of name string, advances the expresssion to the end of the set of contiguous DOS_QMs.

'~.' DOS_DOT - matches either a '.' or zero characters beyond name string.

First and foremost the file system starts off name matching with the expression “*”. If the expression contains a single wild card character ‘*’ all matches are satisfied immediately. This is the most common wild card character used in Windows and expression evaluation is optimized by looking for this character first.

Subsequently evaluation of the “*X” expression is performed. This is a case where the expression starts off with a wild card character and contains some non-wild card characters towards the tail end of the name. This is evaluated by making sure the expression starts off with the character ‘*’ and does not contain any wildcards in the latter part of the expression. The tail part of the expression beyond the first character ‘*’ is matched against the file name at the end uppercasing each character if necessary during the comparison.

The remaining expressions are evaluated in a non deterministic finite order as listed below, where:

'S' is any single character 'S-.' is any single character except the final '.' 'e' is a null character transition 'EOF' is the end of the name string

                       S
                    <-----<
                 X  |     |  e       Y

X * Y == (0)--—>-(1)->--—(2)--—(3)

                      S-.
                    <-----<
                 X  |     |  e       Y

X ~* Y == (0)--—>-(1)->--—(2)--—(3)

                X     S     S     Y

X ?? Y == (0)—(1)—(2)—(3)—(4)

                X     S-.     S-.     Y

X ~?~? == (0)—(1)--—(2)--—(3)—(4) | |_______| | ^ | |_______________| ^EOF of .^

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FilePatternMatchSubExpressionA()

static BOOL FilePatternMatchSubExpressionA ( LPCSTR  lpFileName,
size_t  cchFileName,
LPCSTR  lpX,
size_t  cchX,
LPCSTR  lpY,
size_t  cchY,
LPCSTR  lpWildcard,
LPCSTR *  ppMatchEnd 
)
static

State 2: match Y

State 3: final state

                X     S     Y

X ? Y == (0)—(1)—(2)—(3)

State 2: match Y

State 3: final state

Here is the call graph for this function:
Here is the caller graph for this function: