KeyView allows you to obtain the following basic information for a file:
KVCharSet
enumerated type.ENdocClass
enumerated type.ENdocFmt
enumerated type.ENdocAttributes
enumerated type.You can obtain the file format information by using the fpGetFileInfo()
function pointer.
You call fpGetFileInfo()
with the path to the file, and a pointer to a KVDocInfo
structure that KeyView can fill with the file details. For more details about the fpGetFileInfo()
function pointer, see C API Reference.
The following example illustrates how to:
KVPDFGetInterface
. The pointer to this method is passed into the function as fpGetInterface
in this example. You need this pointer to get other function pointers, including fpInit()
, which must be called first, and fpShutdown()
, which must be called last. For details of how to obtain this pointer, see Get a Session Context.fpInit
.fpGetFileInfo()
method for each path in an array of file names (ppszFileNames
in this example). The file types output are put in the peFileTypesOutput
array of enumerated type ENdocFmt
.fpShutdown()
.NOTE: If a call to fpGetFileInfo
is unsuccessful, the KVDocInfo
structure is not modified. The return value of fpGetFileInfo
is therefore ignored in this example because the KVDocInfo
structure is left zero-filled with the character set equal to KVCS_UNKNOWN
, the document class to set to AutoDetNoFormat
, and the file type of Unknown_Fmt
.
#include "kvpdf.h" void getTypesOfFilesInList( const KVPDFInterface sInterface, const char* const pszKeyViewDir, const char* const pszTempFolder, const char* const * const ppszFileNames, ENdocFmt* const peFileTypesOutput, const unsigned int numberOfFiles) { KVPDFContext context = NULL; unsigned int i = 0; if(sInterface.fpInit( pszKeyViewDir, pszTempFolder, &context ).eErrorCode != KVERR_Success) { return; } for (i = 0; i < numberOfFiles; i++) { // (ENdocFmt) 0 = Unknown_Fmt KVDocInfo sDocInfo = {0}; sInterface.fpGetFileInfo(context, ppszFileNames[i], &sDocInfo); peFileTypesOutput[i] = sDocInfo.adInfo.eFormat; } sInterface.fpShutDown(&context); }
|