Stat (15)
The Stat operation (B_STAT) retrieves the defined characteristics of a file and statistics about the file’s contents, such as the number of records in the file, the number of unique key values stored for each index in the file, and the number of unused pages in the file.
Parameters
 
 
Prerequisites
The file must be open.
Procedure
1
2
3
4
5
6
Details
The MicroKernel Engine returns information about all keys in the file, including those added since file creation. The key information includes any applicable ACS definitions. You must account for this extra information in the data buffer. Specifically, do not use the same data buffer here that you used for the Create (0) operation.
Because the MicroKernel Engine allows up to 119 keys and multiple ACSs in a file, the longest possible data buffer is 33,455 bytes (that is, 16 + (11 * 16) + (119 * 265)). However, you probably do not need such a large data buffer. In fact, you may prefer to specify a smaller data buffer if you want only certain information. For example, you could set the data buffer length to 1920 bytes (that is, 16 + (16 * 119)). In effect, such a setting returns all key information but not necessarily all the ACSs. If your application does not need information about the ACSs, you might prefer this method.
If you specify a value of 0 in the key number parameter, the MicroKernel Engine returns Stat information as shown in the following table.
If you specify a value of -1 in the key number parameter, the MicroKernel Engine returns Stat information as shown in the following table.
File Specifications
The File Specification fields in the returned data buffer are the same as those described for Create (14), with the following exceptions:
Stat does not indicate whether system data was included by default or explicitly.
Key Specifications
The Key Specification fields in the returned data buffer are the same as those described in Table 10, except that a 4-byte Number of Unique Key Values follows the Key Flags field and indicates the number of records that have a unique, nonduplicated value for the specified key.
ACSs
The ACS definitions in the returned data buffer are the same as those described for Create (14).
Result
If the Stat operation is successful, the MicroKernel Engine returns the file and key characteristics to the data buffer and the length of the data buffer in the data buffer length. If the file is an extended file, the MicroKernel Engine returns the file name of the first extension file in the key buffer. If the file name of the first extension file is longer than 63 bytes, the MicroKernel Engine truncates the file name. If the file is not an extended file, the MicroKernel Engine initializes the first byte of the key buffer to 0. (You can use the Stat Extended operation to retrieve statistics regarding extended files.)
If the Stat operation is unsuccessful, the MicroKernel Engine returns one of the following status codes:
Positioning
The Stat operation has no effect on positioning.