The Be Book Release Notes Release Notes Index

The Storage Kit


BMimeType

Declared in:  be/storage/Mime.h
more...



GetSnifferRule() , SetSnifferRule() , CheckSnifferRule()

status_t GetSnifferRule(BString *result) const
status_t SetSnifferRule(const char *rule)
static status_t CheckSnifferRule(const char *rule, BString *parseError)

GetSnifferRule() and SetSnifferRule() get and set the pattern-matching rule that the file type sniffer uses to detect the MIME type represented by this object. The sniffer rule is a string that follows this format:

rating [begin:end] ( [begin:end] 'pattern1' | [begin:end] 'pattern2' | ... )

If no byte range declaration is provided, [0:0] is assumed—i.e. the pattern(s) must start at the first byte.

For example, the following rule strings says that the content of an examined file must begin with the characters 'ABCD':

"1.0 ('ABCD')"

This rule says that the content must contain the characters 'ABCD' or 'abcd' starting somewhere in the first three bytes:

"1.0 [0:3] ('ABCD' | 'abcd')"

Here the content must contain 'ABCD' or 'abcd' starting in the first three bytes, or it must contain 'EFGH' starting at byte 13:

"1.0 [0:3] ('ABCD' | 'abcd' | [13] 'EFGH')"

The CheckSnifferRule() function is a debugging tool that checks your sniffer rule (independent of MIME type) and returns a string that describes the error. If the rule is correct, you get back (in result) a string that says "rule is correct". Otherwise, the result string contains an error message with a pointer to the offending part of the rule. The string is meant to be viewed in a monospace font.


B_SNIFFER_RULE_CHANGED


enum { ... B_SNIFFER_RULE_CHANGED, ... };

B_SNIFFER_RULE_CHANGED is a new MIME database-watching bit vector value. If your application has called BMimeType::StartWatching() and someone changes a sniffer rule, your target will receive a B_META_MIME_CHANGED message that has, as in its "be:which" field, the value B_SNIFFER_RULE_CHANGED.


GuessMimeType()

static status_t GuessMimeType(const entry_ref *file, BMimeType *result)
static status_t GuessMimeType(const void *buffer, int32 length, BMimeType *result)
static status_t GuessMimeType(const char *filename, BMimeType *result)

These new class functions ask the sniffer to identify the MIME type of a file or data. result must be allocated before it's passed in.


BNode

Declared in:  be/storage/Node.h

WriteAttrString() , ReadAttrString()

status_t WriteAttrString(const char *attr, const BString *string)
status_t ReadAttrString(const char *attr, BString *result) const

New functions to more easily work with string-valued file attributes. WriteAttrString() writes a NULL-terminator at the end of the string.


BPath

Declared in:  be/storage/Path.h

BPath has new versions of the constructor and the SetTo() function that accepts entry_ref arguments.


BPath()

BPath(const entry_ref *ref)

SetTo()

status_t SetTo(const entry_ref *ref)

BQuery

Declared in:  be/storage/Query.h

GetPredicate()

status_t GetPredicate(BString *result)

This new version of GetPredicate() returns the query's predicate string as a BString object.


The Be Book Release Notes Release Notes Index

The Be Book,
...in lovely HTML...
for BeOS Release 5.

Copyright © 2000 Be, Inc. All rights reserved..