File Content Extraction 26.1
Filter SDK C++ Programming Guide

# Extract Subfiles

To filter all files in a container file, you must open the container and extract its subfiles to either a file or a stream by using the File Extraction API. The extraction process is done repeatedly until all subfiles are extracted and exposed for filtering. After a subfile is extracted, you can call Filter API methods to filter the data.

If you want to filter a container file and its subfiles, to a single file, you must extract all files from the container, filter the files, and then append each filtered output file to its parent.

You can iterate over subfile information by calling the subfiles method on a document. Each element returned by the iterator contains information about the subfile, and a method to extract it:

Copy

    auto myinput = keyview::io::InputFile{ std::string("InputFile.zip") };
    auto doc = session.open(myinput);

    for (const auto& subfile : doc.subfiles())
    {
        if (!subfile.is_folder())
        {
            auto myoutput = keyview::io::OutputFile{ generateOutputFilePath() };
            subfile.extract(myoutput);
        }
    }

In this example, `generateOutputFilePath()` is a function that returns the name you want to use for the extracted subfile. If the name of the subfile does not matter (for example, the subfile will being passed into File Content Extraction for further processing) you could use a unique identifier like a GUID. If you instead choose to base the filename on `subfile.rawname()` - the path the container file provides - you should ensure you protect against directory traversal attacks (where the name of the subfile contains a relative or absolute path).

NOTE: This very simple example does not account for folders within container files. For a more complete example, see the extract sample program.

NOTE: The subfiles method returns an instance of the `keyview::Container class`, defined in `Keyview_Container.hpp`. This provides access to information about the container, and access to each subfile. The container maintains a reference to the input file, and so cannot be used after the input file has been destroyed.

Copyright 1997-2025 Open Text
Version 26.1 | Last updated January 2026

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: File Content Extraction 26.1

Topic Title: Extract Subfiles