Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 21
Searching For and Matching File-Name Patterns
The following example compares a permanent disk-file name with a map DEFINE
name:
FNAME1 ':=' "\SYSA.$OURVOL.MYSUB.PROGA" -> @S^PTR;
FNAME1^LENGTH := @S^PTR '-' @FNAME1;
FNAME2 ':=' "=MYPROG" -> S^PTR;
FNAME2^LENGTH := @S^PTR '-' @FNAME2;
STATUS := FILENAME_COMPARE_(FNAME1:FNAME1^LENGTH,
FNAME2:FNAME2^LENGTH);
The procedure accepts partially qualified file names and implicitly expands them to
their fully qualified form before comparing.
Searching For and Matching File-Name
Patterns
You can use file-name patterns to search for files. For example, you may want a list of
all disk files on your network whose names begin with the letter Z. To do this, you start
a search for the file-name pattern \*.*.*.Z*.
A search always involves the following procedure calls:
FILENAME_FINDSTART_ establishes the start of a search by providing the file-
name pattern to search for.
FILENAME_FINDNEXT_ is usually called repeatedly. On each call, this procedure
finds the next file name that matches the pattern established by
FILENAME_FINDSTART_.
FILENAME_FINDFINISH_ releases resources used by the search. This procedure
is called when the search is complete.
This subsection describes how to use these procedures. The sample program at the
end of this section includes a procedure that searches for file-name patterns.
In addition to the system procedures listed above, this subsection also describes how
you can match a process qualifier string with a file-name pattern using the
FILENAME_MATCH_ procedure.
Establishing the Start of a File-Name Search
Use FILENAME_FINDSTART_ to set up a search for file names. You can search for
systems, devices, and named processes, or subvolumes, files, and subdevices.
In addition to setting up a pattern to search for, the FILENAME_FINDSTART_
procedure has several options that allow you to do the following: specify the level at
which the subsequent search reports file names, limit a search to device files only,
Caution. Passing an invalid file name to the FILENAME_COMPARE_ procedure can result in
a signal, trap, or data corruption. To verify that a file name is valid, use the
FILENAME_SCAN_ procedure.