YGP::FileTypeCheckerByContent Class Reference

Type to check for type of files by the content of the file. More...

Inherits YGP::FileTypeChecker.

List of all members.

Classes

struct  ID

Public Types

typedef bool(* MATCHFNC )(char *, const char *, unsigned int, std::ifstream &)

Public Member Functions

 FileTypeCheckerByContent ()
 ~FileTypeCheckerByContent ()
virtual unsigned int getType (const char *file) const
void addType (unsigned int type, MATCHFNC fnMatch)
void addType (unsigned int start, unsigned int len, const char *text, unsigned int type, MATCHFNC fnMatch=matchFirstBytes)

Static Public Member Functions

static bool matchFirstBytes (char *buffer, const char *text, unsigned int length, std::ifstream &stream)

Static Protected Member Functions

static bool isHTML (char *buffer, const char *text, unsigned int length, std::ifstream &stream)
static bool isMP3 (char *buffer, const char *text, unsigned int length, std::ifstream &stream)
static bool isOOffice (char *buffer, const char *text, unsigned int length, std::ifstream &stream)
static bool isStarOffice (char *buffer, const char *text, unsigned int length, std::ifstream &stream)
static bool isMSOffice (char *buffer, const char *text, unsigned int length, std::ifstream &stream)
static bool isOfficeOpenXML (char *buffer, const char *text, unsigned int length, std::ifstream &stream)


Detailed Description

Type to check for type of files by the content of the file.

Further types can be added by the addType()-members


Constructor & Destructor Documentation

YGP::FileTypeCheckerByContent::FileTypeCheckerByContent (  ) 

Defaultconstructor.

YGP::FileTypeCheckerByContent::~FileTypeCheckerByContent (  ) 

Destructor.


Member Function Documentation

void YGP::FileTypeCheckerByContent::addType ( unsigned int  start,
unsigned int  len,
const char *  text,
unsigned int  type,
MATCHFNC  fnMatch = matchFirstBytes 
) [inline]

Adds a new handled type.

Parameters:
type Type of file
fnMatch Method to check for file of type

void YGP::FileTypeCheckerByContent::addType ( unsigned int  type,
MATCHFNC  fnMatch 
) [inline]

Adds a new handled type.

Parameters:
type Type of file
fnMatch Method to check for file of type

unsigned int YGP::FileTypeCheckerByContent::getType ( const char *  file  )  const [virtual]

Gets the type of the passed file.

Returns the class of the file (e.g.

Parameters:
file File to analyse
Returns:
unsigned int Type of file
MS Office document) according to passed file-name
Parameters:
file File to inspect
Returns:
unsigned int Class of file

Implements YGP::FileTypeChecker.

bool YGP::FileTypeCheckerByContent::isHTML ( char *  buffer,
const char *  text,
unsigned int  length,
std::ifstream &  stream 
) [static, protected]

Checks if the buffer contains HTML-code; HTML-comments are skipped.

If necessary additional data is read from the stream

Parameters:
buffer Buffer to inspect
text Text to match
length Number of bytes to check
stream Stream from where to read more characters
Returns:
bool True, if the text matches

bool YGP::FileTypeCheckerByContent::isMP3 ( char *  buffer,
const char *  text,
unsigned int  length,
std::ifstream &  stream 
) [static, protected]

Checks if the first two bytes in the buffer are an MP3-ID tag.

Parameters:
buffer Buffer to inspect
text Text to match
length Number of bytes to check
stream Stream from where to read more characters
Returns:
bool True, if the text matches

bool YGP::FileTypeCheckerByContent::isMSOffice ( char *  buffer,
const char *  text,
unsigned int  length,
std::ifstream &  stream 
) [static, protected]

Checks if the first bytes in buffer identify a MSOffice-document.

As StarOffice- documents have the same identifier, check position 0xc2 of the stream if it does not contain a StarOffice-identifier.

Parameters:
buffer Buffer to inspect
text Text to match
length Number of bytes to check
stream Stream from where to read more characters
Returns:
bool True, if the text matches

bool YGP::FileTypeCheckerByContent::isOfficeOpenXML ( char *  buffer,
const char *  text,
unsigned int  length,
std::ifstream &  stream 
) [static, protected]

Checks if the passed stream is an MS-Office 2007 document.

Parameters:
buffer Buffer to inspect (ignored)
text Text to match (ignored)
length Number of bytes to check (ignored)
stream Stream from where to read more characters
Returns:
bool True, if the text matches

bool YGP::FileTypeCheckerByContent::isOOffice ( char *  buffer,
const char *  text,
unsigned int  length,
std::ifstream &  stream 
) [static, protected]

Checks if the first four bytes in buffer identify a ZIP-archive.

If so, check if the file could be an OpenOffice-document

Parameters:
buffer Buffer to inspect (ignored)
text Text to match (ignored)
length Number of bytes to check (ignored)
stream Stream from where to read more characters
Returns:
bool True, if the text matches

bool YGP::FileTypeCheckerByContent::isStarOffice ( char *  buffer,
const char *  text,
unsigned int  length,
std::ifstream &  stream 
) [static, protected]

Checks if the first bytes in buffer identify a MSOffice-document which also identifies a StarOffice-document.

The latter has another identifier at position 0xc2.

Parameters:
buffer Buffer to inspect
text Text to match
length Number of bytes to check
stream Stream from where to read more characters
Returns:
bool True, if the text matches

bool YGP::FileTypeCheckerByContent::matchFirstBytes ( char *  buffer,
const char *  text,
unsigned int  length,
std::ifstream &  stream 
) [static]

Checks if the first bytes in buffer machtes the passed value.

Parameters:
buffer Buffer to inspect
text Text to match
length Number of bytes to check
stream Stream from where to read more characters
Returns:
bool True, if the text matches


The documentation for this class was generated from the following files:

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:27 2009 by doxygen 1.5.8