Guardian Programmer's Guide

Table Of Contents
Using the File System
Guardian Programmer’s Guide 421922-014
2 - 12
Creating Files
The second parameter designates the actual length of the supplied file name. File
names are variable length, so it is necessary to tell the operating system how many
bytes to expect. In this case, pointers have been used to identify each end of the file-
name string before computing the string length.
To create a temporary file, use the FILE_CREATE_ procedure without specifying the
subvolume or file ID of the name. For example:
NAME ':=' "$OURVOL" -> @S^PTR;
LENGTH := @S^PTR '-' @NAME;
ERROR := FILE_CREATE_(NAME:ZSYS^VAL^LEN^FILENAME,
LENGTH);
Here, a temporary file is created somewhere on the volume $OURVOL. The name of
the temporary file is returned in the NAME variable, and the name length in LENGTH.
In this case, you should use the ZSYS^VAL^LEN^FILENAME literal to allow future
expansion of the file name, because the length of the file name is not known on input.
Allocating Extents
So far no attention has been paid to how the operating system allocates disk space for
a created file. It does so in extents, where an extent is a physically contiguous area of
disk that may be as small as 2048 bytes or as large as 128 megabytes (MB). While
applications see a file as a logically contiguous area of storage, the operating system
splits the file space into extents. Figure 2-2 shows an example of a file split into three
extents.
If you do not specify an extent size, the operating system uses the default extent size
of one page (2048 bytes). Smaller extents mean less wasted allocated disk space, but
CPU overhead is reduced by having larger extents because there are fewer extents to
manage. A smaller extent size is therefore suitable for small files because it wastes
less disk space. Larger files can be managed more efficiently with larger extents,
because that results in fewer extents to manage.
Each file that is not empty is made up of at least one extent, the primary extent; an
empty file has no extents. If a file is larger than the primary extent size, additional
Figure 2-2. File Space Allocated in Extents
VST007.VSD