glibmm: Platform-specific content typing
A content type is a platform specific string that defines the type of a file. More...
Functions | |
| bool | Gio::content_type_equals (const Glib::ustring& type1, const Glib::ustring& type2) |
| Compares two content types for equality. More... | |
| bool | Gio::content_type_is_a (const Glib::ustring& type, const Glib::ustring& supertype) |
| Determines if type is a subset of supertype. More... | |
| bool | Gio::content_type_is_unknown (const Glib::ustring& type) |
| Checks if the content type is the generic "unknown" type. More... | |
| Glib::ustring | Gio::content_type_get_description (const Glib::ustring& type) |
| Gets the human readable description of the content type. More... | |
| Glib::ustring | Gio::content_type_get_mime_type (const Glib::ustring& type) |
| Gets the mime-type for the content type, if one is registered. More... | |
| Glib::RefPtr< Icon > | Gio::content_type_get_icon (const Glib::ustring& type) |
| Gets the icon for a content type. More... | |
| Glib::RefPtr< Icon > | Gio::content_type_get_symbolic_icon (const Glib::ustring& type) |
| Gets the symbolic icon for a content type. More... | |
| bool | Gio::content_type_can_be_executable (const Glib::ustring& type) |
| Checks if a content type can be executable. More... | |
| Glib::ustring | Gio::content_type_from_mime_type (const Glib::ustring& mime_type) |
| Tries to find a content type based on the mime type name. More... | |
| Glib::ustring | Gio::content_type_guess (const std::string& filename, const guchar* data, gsize data_size, bool& result_uncertain) |
| Guesses the content type based on example data. More... | |
| Glib::ustring | Gio::content_type_guess (const std::string& filename, const std::string& data, bool& result_uncertain) |
| Guesses the content type based on example data. More... | |
| Glib::StringArrayHandle | Gio::content_type_guess_for_tree (const Glib::RefPtr< const File >& root) |
| Tries to guess the type of the tree with root root, by looking at the files it contains. More... | |
| Glib::ListHandle< Glib::ustring > | Gio::content_types_get_registered () |
| Gets a list of strings containing all the registered content types known to the system. More... | |
Detailed Description
A content type is a platform specific string that defines the type of a file.
On UNIX it is a mime type like "text/plain" or "image/png". On Win32 it is an extension string like ".doc", ".txt" or a perceived string like "audio". Such strings can be looked up in the registry at HKEY_CLASSES_ROOT.
Function Documentation
| bool Gio::content_type_can_be_executable | ( | const Glib::ustring& | type) |
Checks if a content type can be executable.
Note that for instance things like text files can be executables (i.e. scripts and batch files).
- Parameters
-
type a content type string.
- Returns
- true if the file type corresponds to a type that can be executable, false otherwise.
| bool Gio::content_type_equals | ( | const Glib::ustring& | type1, |
| const Glib::ustring& | type2 | ||
| ) |
Compares two content types for equality.
- Parameters
-
type1 A content type string. type2 A content type string.
- Returns
- true if the two strings are identical or equivalent, false otherwise.
| Glib::ustring Gio::content_type_from_mime_type | ( | const Glib::ustring& | mime_type) |
Tries to find a content type based on the mime type name.
- Parameters
-
mime_type a mime type string.
- Returns
- string with content type or empty when it does not know.
| Glib::ustring Gio::content_type_get_description | ( | const Glib::ustring& | type) |
Gets the human readable description of the content type.
- Parameters
-
type A content type string.
- Returns
- a short description of the content type type.
| Glib::RefPtr<Icon> Gio::content_type_get_icon | ( | const Glib::ustring& | type) |
Gets the icon for a content type.
- Parameters
-
type A content type string.
- Returns
- Icon corresponding to the content type.
| Glib::ustring Gio::content_type_get_mime_type | ( | const Glib::ustring& | type) |
Gets the mime-type for the content type, if one is registered.
- Parameters
-
type A content type string.
- Returns
- the registered mime-type for the given type, or an empty string if unknown.
| Glib::RefPtr<Icon> Gio::content_type_get_symbolic_icon | ( | const Glib::ustring& | type) |
Gets the symbolic icon for a content type.
- Parameters
-
type A content type string.
- Returns
- symbolic Icon corresponding to the content type.
| Glib::ustring Gio::content_type_guess | ( | const std::string & | filename, |
| const guchar * | data, | ||
| gsize | data_size, | ||
| bool & | result_uncertain | ||
| ) |
Guesses the content type based on example data.
If the function is uncertain, result_uncertain will be set to true. Either filename may be an empty string or data may be 0, in which case the guess will be based solely on the other argument.
- Parameters
-
filename a string. data A stream of data. data_size The size of data. [out] result_uncertain A flag indicating the certainty of the result.
- Returns
- A string indicating a guessed content type for the given data.
| Glib::ustring Gio::content_type_guess | ( | const std::string & | filename, |
| const std::string & | data, | ||
| bool & | result_uncertain | ||
| ) |
Guesses the content type based on example data.
If the function is uncertain, result_uncertain will be set to true. filename may be an empty string, in which case the guess will be based solely on data.
- Parameters
-
filename a string. data A stream of data. [out] result_uncertain A flag indicating the certainty of the result.
- Returns
- A string indicating a guessed content type for the given data.
| Glib::StringArrayHandle Gio::content_type_guess_for_tree | ( | const Glib::RefPtr< const File >& | root) |
Tries to guess the type of the tree with root root, by looking at the files it contains.
The result is a list of content types, with the best guess coming first.
The types returned all have the form x-content/foo, e.g. x-content/audio-cdda (for audio CDs) or x-content/image-dcf (for a camera memory card). See the shared-mime-info specification for more on x-content types.
- Parameters
-
root The root of the tree to guess a type for.
- Returns
- List of zero or more content types.
| bool Gio::content_type_is_a | ( | const Glib::ustring& | type, |
| const Glib::ustring& | supertype | ||
| ) |
Determines if type is a subset of supertype.
- Parameters
-
type A content type string. supertype A content type string.
- Returns
- true if type is a kind of supertype, false otherwise.
| bool Gio::content_type_is_unknown | ( | const Glib::ustring& | type) |
Checks if the content type is the generic "unknown" type.
On unix this is the "application/octet-stream" mimetype, while on win32 it is "*".
- Parameters
-
type A content type string.
- Returns
- true if the type is the unknown type.
| Glib::ListHandle<Glib::ustring> Gio::content_types_get_registered | ( | ) |
Gets a list of strings containing all the registered content types known to the system.
- Returns
- List of the registered content types.
