## Chapter 15. CFL Creation Utility

## Overview

A CFL file is conceptually a lot like any other compressed archive file format, such as ZIP. CFL files can be mounted by X-Forge to appear to the application as if the files inside the CFL are uncompressed and simply part of the normal file system. When opening a file from an X-Forge application, the actual filesystem will be searched first - then the mounted CFL files.

The CFL creation utility is called `makecfl.exe` and can be found in the `tools` directory of the X-Forge distribution.

## Creating a CFL file

Creating a CFL file is a two part process. First, an `.ini` is created, which determines which files you want to include in the CFL file, using what compressions and with what filenames. Second, the `.ini` file is used to actually create a `.cfl` file. The same `.ini` file can then be used in the future to re-create the `.cfl` file.

To create the `.ini` file, run the `makecfl` utility with the -i switch, for example like this:

    makecfl -i foo.ini

This will create a file called `foo.ini` that includes a list of files that will be included in the final `.cfl` file. You can now edit the list manually with a text editor and change options regarding how the file should be included into the `.cfl` file. You can select the compression algorithm and encryption, but in most cases, the default values work well. You can also add or remove files to the list.

To create the final `.cfl` file using the `.ini` file, you run the `makecfl` utility one more time, this time with the -b switch as shown below:

    makecfl -b foo.ini

This will produce the final CFL archive file called `foo.cfl`, which contains all the files specified in the foo.ini file. The file is now ready to be used from an X-Forge application.

## Using a CFL file from an X-Forge application

Using CFL files from an X-Forge application is very simple. All one needs to do is mount the file using the `XFcCore::openCFL()`. After this, all file operations can be performed as normal, as if the file was in the actual file system.

### Note

Opening a file from a CFL causes the entire file to be uncompressed, which causes a memory peak for as long as the file is open. It is thus a good idea to close files as soon as they are no longer needed.

|  | X-Forge Documentation Confidential Copyright © 2003 Fathammer