## GContentType GContentType — Platform-specific content typing |

## Functions

gboolean | g_content_type_equals ()
gboolean | g_content_type_is_a ()
gboolean | g_content_type_is_mime_type ()
gboolean | g_content_type_is_unknown ()
gchar * | g_content_type_get_description ()
gchar * | g_content_type_get_mime_type ()
GIcon * | g_content_type_get_icon ()
GIcon * | g_content_type_get_symbolic_icon ()
gchar * | g_content_type_get_generic_icon_name ()
gboolean | g_content_type_can_be_executable ()
gchar * | g_content_type_from_mime_type ()
gchar * | g_content_type_guess ()
gchar ** | g_content_type_guess_for_tree ()
GList * | g_content_types_get_registered ()

## Includes

    #include <gio/gio.h>

## 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`. On macOS it is a Uniform Type Identifier such as `com.apple.application`.

## Functions

### g_content_type_equals ()

    gboolean
    g_content_type_equals (const gchar *type1,
                           const gchar *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.

### g_content_type_is_a ()

    gboolean
    g_content_type_is_a (const gchar *type,
                         const gchar *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.

### g_content_type_is_mime_type ()

    gboolean
    g_content_type_is_mime_type (const gchar *type,
                                 const gchar *mime_type);

Determines if `type` is a subset of `mime_type` . Convenience wrapper around `g_content_type_is_a()`.

#### Parameters

type | a content type string |
mime_type | a mime type string |

#### Returns

`TRUE` if `type` is a kind of `mime_type` , `FALSE` otherwise.

Since: 2.52

### g_content_type_is_unknown ()

    gboolean
    g_content_type_is_unknown (const gchar *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 "*" and on OSX it is a dynamic type or octet-stream.

#### Parameters

type | a content type string |

#### Returns

`TRUE` if the type is the unknown type.

### g_content_type_get_description ()

    gchar *
    g_content_type_get_description (const gchar *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` . Free the returned string with `g_free()`

### g_content_type_get_mime_type ()

    gchar *
    g_content_type_get_mime_type (const gchar *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 `NULL` if unknown; free with `g_free()`.

[nullable][transfer full]

### g_content_type_get_icon ()

    GIcon *
    g_content_type_get_icon (const gchar *type);

Gets the icon for a content type.

#### Parameters

type | a content type string |

#### Returns

GIcon corresponding to the content type. Free the returned object with `g_object_unref()`.

[transfer full]

### g_content_type_get_symbolic_icon ()

    GIcon *
    g_content_type_get_symbolic_icon (const gchar *type);

Gets the symbolic icon for a content type.

#### Parameters

type | a content type string |

#### Returns

symbolic GIcon corresponding to the content type. Free the returned object with `g_object_unref()`.

[transfer full]

Since: 2.34

### g_content_type_get_generic_icon_name ()

    gchar *
    g_content_type_get_generic_icon_name (const gchar *type);

Gets the generic icon name for a content type.

See the shared-mime-info specification for more on the generic icon name.

#### Parameters

type | a content type string |

#### Returns

the registered generic icon name for the given `type` , or `NULL` if unknown. Free with `g_free()`.

[nullable]

Since: 2.34

### g_content_type_can_be_executable ()

    gboolean
    g_content_type_can_be_executable (const gchar *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.

### g_content_type_from_mime_type ()

    gchar *
    g_content_type_from_mime_type (const gchar *mime_type);

Tries to find a content type based on the mime type name.

#### Parameters

mime_type | a mime type string |

#### Returns

Newly allocated string with content type or `NULL`. Free with `g_free()`.

[nullable]

Since: 2.18

### g_content_type_guess ()

    gchar *
    g_content_type_guess (const gchar *filename,
                          const guchar *data,
                          gsize data_size,
                          gboolean *result_uncertain);

Guesses the content type based on example data. If the function is uncertain, `result_uncertain` will be set to `TRUE`. Either `filename` or `data` may be `NULL`, in which case the guess will be based solely on the other argument.

#### Parameters

filename | a string, or `NULL`. | [nullable]
data | a stream of data, or `NULL`. | [nullable][array length=data_size]
data_size | the size of `data` |
result_uncertain | return location for the certainty of the result, or `NULL`. | [out][optional]

#### Returns

a string indicating a guessed content type for the given data. Free with `g_free()`

### g_content_type_guess_for_tree ()

    gchar **
    g_content_type_guess_for_tree (GFile *root);

Tries to guess the type of the tree with root `root` , by looking at the files it contains. The result is an array 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.

This function is useful in the implementation of `g_mount_guess_content_type()`.

#### Parameters

root | the root of the tree to guess a type for |

#### Returns

an `NULL`-terminated array of zero or more content types. Free with `g_strfreev()`.

[transfer full][array zero-terminated=1]

Since: 2.18

### g_content_types_get_registered ()

    GList *
    g_content_types_get_registered (void);

Gets a list of strings containing all the registered content types known to the system. The list and its data should be freed using `g_list_free_full (list, g_free)`.

#### Returns

list of the registered content types.

[element-type utf8][transfer full]