Specifies whether a temporary file is used during CHM generation.
The CHM file format includes data about the compressed section (such as its overall size) that is stored in the output CHM file prior to the compressed section itself. This unavoidably requires that the compressed section has to be generated, before these details can be set. There are several ways this can be handled. Firstly, the compressed section could be generated entirely in memory before writing any of the output CHM file. This approach is not used in libmspack, as the compressed section can exceed the addressable memory space on most architectures.
libmspack has two options, either to write these unknowable sections with blank data, generate the compressed section, then re-open the output file for update once the compressed section has been completed, or to write the compressed section to a temporary file, then write the entire output file at once, performing a simple file-to-file copy for the compressed section.
The simple solution of buffering the entire compressed section in memory can still be used, if desired. As the temporary file's filename is passed directly to mspack_system::open(), it is possible for a custom mspack_system implementation to hold this file in memory, without writing to a disk.
If a temporary file is set, generate() performs the following sequence of events: the temporary file is opened for writing, the compression algorithm writes to the temporary file, the temporary file is closed. Then the output file is opened for writing and the temporary file is re-opened for reading. The output file is written and the temporary file is read from. Both files are then closed. The temporary file itself is not deleted. If that is desired, the temporary file should be deleted after the completion of generate(), if it exists.
If a temporary file is set not to be used, generate() performs the following sequence of events: the output file is opened for writing, then it is written and closed. The output file is then re-opened for update, the appropriate sections are seek()ed to and re-written, then the output file is closed.