14.  File Insertions

      The primitive file-insertions is a general-purpose utility for inserting strings into files at specified locations in a fast and robust way. One application is to resolve forward references of any kind among a group of files when all files have been processed. In this case, the insertions would be executed by an exit event handler.

(file-insertions insertions)

      insertions is a list specifying the parameters for the file insertions. Each element of the list is itself a list consisting of a file name (a string), a file offset (an integer between zero and the size of the file), and a string to be inserted in the given file at the given offset. file-insertions sorts the list to ensure that each file is only processed once and that the offsets for each file are in increasing order. Then each file is copied to a temporary file

filename.new
(where filename is the original file name), and the specified insertions are carried out as the file is copied. When processing of a file is finished, the temporary file is renamed to its original name. If there exist links to a file, a warning is displayed and the insertion is skipped.


Markup created by unroff 1.0,    March 21, 1996,    net@informatik.uni-bremen.de