Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 5
Scanning a String for a Valid File Name
You pass a string to the FILENAME_SCAN_ procedure for testing. If the file name or
pattern is valid, the procedure returns the following information:
The length in bytes of the file name or pattern.
An indication of the kind of object that the name or pattern identifies: file name,
file-name pattern, or DEFINE name.
The level of the specified object, that is, whether the name identifies a network
node, device or process, subvolume, or disk-file name.
If the string does not contain a valid file name or file-name pattern, then the procedure
returns error value 13 (illegal file name).
Note that the FILENAME_SCAN_ procedure does not check the entire input string. If
the front part of the string contains a valid file name or pattern, then the rest of the
string is ignored. If you need to check that the entire string has been tested, you
should include a test that the string length is equal to the byte count returned by the
FILENAME_SCAN_ procedure.
In addition to the default action of scanning for a file name, the FILENAME_SCAN_
procedure is also able to scan for a valid subvolume name or for a name pattern. The
following paragraphs describe how.
Scanning File Names and Node Names
To scan a string for the existence of any kind of valid file name or node name, you use
the FILENAME_SCAN_ procedure without any options. The default action of the
FILENAME_SCAN_ procedure is to accept any syntactically valid file name (including
disk-file name, DEFINE name, process file name, or device name) or node name;
subvolume names are rejected, as are name patterns.
The following example scans a string in the first STRING^LENGTH bytes of
STRING^BUFFER. The value of STRING^LENGTH is compared to the returned value
of COUNT to verify that the entire string has been checked:
ERROR := FILENAME_SCAN_(STRING^BUFFER:STRING^LENGTH,
COUNT,
KIND,
LEVEL);
IF ERROR <> 0 OR
COUNT <> STRING^LENGTH THEN ... ! Error condition