# Filtering in File Mode

To use the Filter file-based I/O

1. Load the `kvfilter` library and obtain the `KV_GetFilterInterfaceEx()` entry point by calling KV_GetFilterInterfaceEx(). The `filter` sample program contains sample code for all platforms.
2. Initialize a filter session by calling fpInit() or fpInitWithLicenseData(). This function's return value, `pContext`, is passed as the first argument to the File Extraction interface and all other Filter functions.
3. Pass the context pointer from fpInit() or fpInitWithLicenseData() and the address of a structure that contains pointers to the File Extraction API functions in the call to KVGetExtractInterface().
4. Declare the file path in the KVOpenFileArg structure.
5. Open the file by calling fpOpenFile() and passing the `KVOpenFileArg` structure. This call defines the parameters necessary to open a file for extraction.
6. Determine whether the source file is a container file (that is, whether it contains subfiles) by calling fpGetMainFileInfo().
7. If the call to `fpGetMainFileInfo()` determined that the source file contains subfiles, proceed to step 8; otherwise, proceed to step 11.
8. Determine whether the subfile is a container file by calling fpGetSubFileInfo().
9. Extract the subfile or subfiles to a file by calling fpExtractSubFile() and setting `filePath` and `extractDir` in the `KVExtractSubFileArg` structure.
10. If the call to `fpGetSubFileInfo()` determined that the subfile is a container file, repeat step 4 through step 9 until all subfiles are extracted; otherwise, proceed to step 11.
11. Filter the file by calling fpFilterFile().
12. Close the file by calling fpCloseFile().
13. Repeat step 4 through step 12 as required for additional source files.
14. Terminate the filter session by calling fpShutdown().

© Copyright 2016-2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm