Skip to main content
Version: 16.10.0

GW2DetermineFileTypeFromFile

The GW2DetermineFileTypeFromFile function determines the file type for the given file. If it cannot discern the file type, it returns the value of the enumeration constant ft_unknown from the enumerated type ft_t ; otherwise, it returns a value from the enumerated type ft_t indicating the file type.


#include "glasswall.core2.api.h"

ft_t GW2DetermineFileTypeFromFile(const char *path);

Parameters

path The absolute file path to the file you wish to examine.

Returns

  Enumerated type ft_t indicating the determined file type. If the file type cannot be determined then ft_unknown will be returned.

Example

#include "glasswall.core2.api.h"
#include “filetype.h”

ft_t file_type = GW2DetermineFileTypeFromFile("c:\\dir1\\dir2\\filename");
char *type = NULL;
switch (file_type) /* categorise them */
{
case ft_doc:
case ft_docx:
case ft_ppt:
case ft_pptx:
case ft_xls:
case ft_xlsx:
type = "Microsoft Office";
break;

case ft_png:
case ft_jpg:
case ft_gif:
case ft_tiff:
type = "Image file";
break;

case ft_pdf:
type = "PDF";
break;

default:
type = "Unrecognised file type";
break;
}