Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 32
File-Name Matching
BEGIN
2 -> !Complete match
1 -> !Incomplete match
0 -> !No match
OTHERWISE -> !Error
END;
Testing for an Incomplete Match
An incomplete match status value (1) is returned if the name under test matches the
left-hand portion of a pattern but not the entire pattern. For example, if the name under
test is \SYSA.$OURVOL and the pattern is \*.*.*, then the procedure returns an
incomplete match.
The incomplete match can be useful in eliminating needless name searching where
large hierarchies are involved. For example, you can test the node name and volume
name for an incomplete match before going on to test for a match at the process and
process-qualifier level.
The following example extracts the volume prefix from a name and checks for an
incomplete match with the file-name pattern. If the match is successful, then the code
checks the entire string.
LITERAL MAXLEN := 256;
LITERAL VOLUME := 0;
LITERAL EXTRACT^PREFIX = %B0000000000000010;
.
.
!Scan the file name to check that it is valid:
ERROR := FILENAME_SCAN_(STRING:LENGTH,
NAME^LENGTH);
IF ERROR <> 0 THEN ... ! Error condition
ELSE
BEGIN
!Expand the file name to its fully qualified form:
ERROR := FILENAME_RESOLVE_(STRING:NAME^LENGTH,
FULLNAME:MAXLEN,
FULL^LENGTH);
IF ERROR <> 0 THEN ... !Error condition
END;
!Extract the volume-level prefix:
LEVEL := VOLUME;
OPTIONS := EXTRACT^PREFIX;
CALL FILENAME_DECOMPOSE_(FULLNAME:FULL^LENGTH,
PREFIX:MAXLEN,
PREFIX^LENGTH,
LEVEL,
OPTIONS);
PATTERN ':=' "\*.*.*.*" -> @S^PTR;
PATTERN^LENGTH := @S^PTR '-' @PATTERN;