Guardian Programmer's Guide

Table Of Contents
Manipulating File Names
Guardian Programmer’s Guide 421922-014
13 - 16
Extracting Pieces of File Names
ERROR := FILENAME_DECOMPOSE_(FNAME:LENGTH,
PART:MAXLEN,
PART^LENGTH,
SUBVOL^LEVEL);
IF ERROR <> 0 THEN ... !Error condition
Here, the file name is passed in FNAME. The subvolume name is returned in PART
and its length in PART^LENGTH. MAXLEN is set to 16 to allow for the maximum size
of a subvolume pattern.
The part that you want returned is specified in the level parameter (SUBVOL^LEVEL
in the previous example). It can have one of the following values:
Extracting a File-Name Suffix or a File-Name Prefix
In addition to returning the requested element, you can have the
FILENAME_DECOMPOSE_ procedure return all elements to the right of the requested
element by setting the extract-suffix flag (bit 15) in the options parameter to 1.
Similarly, you can return all elements to the left of the selected element as well as the
selected element itself by setting the extract-prefix flag (bit 14) in the options
parameter to 1 before calling the FILENAME_DECOMPOSE_ procedure.
The following example extracts a file-name suffix, the first part of which is the
subvolume name:
LITERAL MAXLEN = 32;
LITERAL SUBVOL^LEVEL = 2;
LITERAL EXTRACT^SUFFIX = %B0000000000000001;
.
.
OPTIONS := EXTRACT^SUFFIX;
ERROR := FILENAME_DECOMPOSE_(FNAME:LENGTH,
SUFFIX^PIECE:MAXLEN,
SUFFIX^LENGTH,
SUBVOL^LEVEL,OPTIONS);
IF ERROR <> 0 THEN ... !Error condition
Extracting File-Name Pieces Without Implicit Resolution
You can exclude all default values from the returned shortened name by setting the
no-defaults flag (bit 13) in the options parameter to 1 before calling the
FILENAME_DECOMPOSE_ procedure. In other words, setting the no-defaults flag
turns off implicit resolution of partially qualified file names.
-1 Returns the node name.
0 Returns the device name, process name, or logical device name.
1 Returns the subvolume name for permanent disk files or returns the temporary
file ID for temporary files.
2 Returns the file ID for permanent disk files.