|
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' | ... )
- rating is a mandatory float between 0.0 and 1.0 that describes the priority of the rule, compared to other rules for the same type.
- [begin:end] is the optional "global byte range" declaration. The sniffer will look for a matching pattern that begins within this range of data. The [begin:end] that appears outside the parenthesis (i.e. just after rating) applies to all the patterns for this rule. If a pattern must begin at a particular byte offset, you can exclude the ":end" declaration.
- 'pattern1', 'pattern2', etc. These are the patterns themselves. You can OR patterns with the "|" operator. (You can't AND patterns.) An immediately preceding byte range declaration applies to the following pattern (only), and overrides the global byte range declaration.
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.
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.
Declared in: be/storage/Path.hBPath 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)
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.
|
Copyright © 2000 Be, Inc. All rights reserved..