Inherits YGP::FileTypeChecker.
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) |
Further types can be added by the addType()-members
YGP::FileTypeCheckerByContent::FileTypeCheckerByContent | ( | ) |
Defaultconstructor.
YGP::FileTypeCheckerByContent::~FileTypeCheckerByContent | ( | ) |
Destructor.
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.
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.
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.
file | File to analyse |
file | File to inspect |
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
buffer | Buffer to inspect | |
text | Text to match | |
length | Number of bytes to check | |
stream | Stream from where to read more characters |
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.
buffer | Buffer to inspect | |
text | Text to match | |
length | Number of bytes to check | |
stream | Stream from where to read more characters |
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.
buffer | Buffer to inspect | |
text | Text to match | |
length | Number of bytes to check | |
stream | Stream from where to read more characters |
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.
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 |
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
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 |
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.
buffer | Buffer to inspect | |
text | Text to match | |
length | Number of bytes to check | |
stream | Stream from where to read more characters |
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.
buffer | Buffer to inspect | |
text | Text to match | |
length | Number of bytes to check | |
stream | Stream from where to read more characters |