Opening files using temporary file descriptions

 

Temporary changes can provide greater flexibility to the application. The system makes temporary changes when the program is first establishing a path to the file by opening the file.

Temporary changes can be made in one of the following ways:

The ability to use the first way depends very much on which programming language you used to write the program. Some programming languages do not allow you to control the open process to any great extent. These languages do the open process more or less automatically and control what information gets passed. Other languages allow you to have greater control over the open process.

You can use the second option regardless of which programming language you use. The i5/OS® operating system provides override CL commands for each file type. By including override commands with the application, you can temporarily change the file description in a file that the program wants to use. You can use both options together. Information that is contained in the application can change some parameters; an override command can change others. Both can change the same parameter. The operating system follows this order when making temporary changes to a file:

  1. The file description provides a base of information.

  2. Change information received from the application during the open process is applied first to the base information.

  3. Change information found in the override command is applied last. If both the change information from the application and the override change the same information, the override has precedence.

Only the application that makes the changes can see the temporary changes. The file, as seen by another application, remains unchanged. In fact, two applications can use the same file at the same time, and each can change it temporarily according to its needs. Neither application is aware the other has made a temporary change. Figure 1 and Figure 2 illustrate the permanent and temporary change processes. Figure 1. Permanently changing a File

The process for permanently changing a file. Figure 2. Temporarily changing a File

The process for temporarily changing a file.

Once an application establishes a connection between itself and the file by opening the file, it can then proceed to use the file for either input or output operations. In the case of a database file, the open process establishes a path between the application and the actual database file. For device files, a path is established between the application and the actual device, or to a spooled file if the spooling attribute is active for the device file. In all cases, the application connects to what it wants to use, and those connections determine what input or output operations are valid. Not all operations are valid with all file types. The application must be aware of what file types it uses and then use only those operations which are valid for those types.

 

Parent topic:

Opened files