2 * Copyright 2013-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Ingo Weinhold, bonefish@users.sf.net
7 * John Scipione, jscipione@gmail.com
10 * headers/os/storage/Mime.h hrev47402
11 * src/kits/storage/Mime.cpp hrev47402
19 \brief Provides C and Haiku-only C++ MIME-type handling functions.
26 \brief Legacy BeOS icon size constants.
33 \var icon_size B_LARGE_ICON
42 \var icon_size B_MINI_ICON
51 \var B_UPDATE_MIME_INFO_NO_FORCE
52 \brief Files that already have a \c BEOS:TYPE attribute won't be updated.
59 \var B_UPDATE_MIME_INFO_FORCE_KEEP_TYPE
60 \brief Files that already have a \c BEOS:TYPE attribute will be updated
61 too, but \c BEOS:TYPE itself will remain untouched.
68 \var B_UPDATE_MIME_INFO_FORCE_UPDATE_ALL
69 \brief Similar to \c B_UPDATE_MIME_INFO_FORCE_KEEP_TYPE, but the
70 \c BEOS:TYPE attribute will be updated too.
77 \fn int update_mime_info(const char* path, int recursive, int synchronous,
79 \brief Updates the MIME information (i.e MIME type) for one or more files.
81 If \a path points to a file, the MIME information for this file are
82 updated only. If it points to a directory and \a recursive is non-null,
83 the information for all the files in the given directory tree are updated.
84 If path is \c NULL all files are considered; \a recursive is ignored in
87 \param path The path to a file or directory, or \c NULL.
88 \param recursive Triggers recursive behavior if not \c NULL.
89 \param synchronous If not \c NULL update_mime_info() waits until the
90 operation is finished, otherwise it returns immediately and the
91 update is done asynchronously.
92 \param force Specifies how to handle files that already have MIME
93 information. See enum definitions for more information:
94 - \c B_UPDATE_MIME_INFO_NO_FORCE
95 - \c B_UPDATE_MIME_INFO_FORCE_KEEP_TYPE
96 - \c B_UPDATE_MIME_INFO_FORCE_UPDATE_ALL
98 \return A status code, \c B_OK if everything went fine, an error code
106 \fn status_t create_app_meta_mime(const char* path, int recursive,
107 int synchronous, int force)
108 \brief Creates a MIME database entry for one or more applications.
110 If \a path points to an application file, a MIME DB entry is create for
111 the application. If it points to a directory and \a recursive is not
112 \c NULL then entries are created for all application files in the given
113 directory tree. If path is \c NULL then all files are considered and
114 \a recursive is ignored.
116 \param path The path to an application file, a directory, or \c NULL.
117 \param recursive Trigger recursive behavior if not \c NULL.
118 \param synchronous Waits until the operation is finished if not \c NULL,
119 otherwise it returns immediately and the operation is done
121 \param force Entries are created even if they do already exist if not
124 \return A status code, \c B_OK if everything went fine, an error code
132 \fn status_t get_device_icon(const char* device, void* icon, int32 size)
133 \brief Retrieves an icon associated with a given device.
135 \param device The path to the device.
136 \param icon A pointer to a buffer the icon data shall be written to.
137 \param size The size of the icon to retrieve. Currently 16
138 (\c B_MINI_ICON) and 32 (\c B_LARGE_ICON) are supported.
140 \return A status code, \c B_OK if everything went fine, an error code
142 \retval B_OK Retrieved the icon successfully.
143 \retval B_BAD_VALUE \a device or \a icon was \c NULL.
144 \retval B_NO_MEMORY Ran out of memory allocating bitmap.
151 \fn status_t get_device_icon(const char* device, BBitmap* icon,
153 \brief Retrieves an icon associated with a given device into a BBitmap,
156 \param device The path to the device.
157 \param icon A pointer to a pre-allocated BBitmap of the correct dimension
158 to store the requested icon (16x16 for the mini and 32x32 for the
160 \param which The size of the icon to retrieve. Currently 16
161 (\c B_MINI_ICON) and 32 (\c B_LARGE_ICON) are supported.
163 \return A status code, \c B_OK if everything went fine, an error code
165 \retval B_OK Retrieved the icon successfully.
166 \retval B_BAD_VALUE \a device or \a icon was \c NULL.
173 \fn status_t get_device_icon(const char* device, uint8** _data,
174 size_t* _size, type_code* _type);
175 \brief Try to get the icon by name first, if that fails try to get the
176 vector icon, C++ only.
178 \param device The path to the device.
179 \param _data A pointer to a pointer to an array of uint8 pixel data to
181 \param _size The size of the icon to fill out. If vector, it is filled in
182 with the width in pixels, if bitmap, one of the following constants:
185 \param _type The icon type code to fill out, one of the following:
186 - \c B_MINI_ICON_TYPE
187 - \c B_LARGE_ICON_TYPE
188 - \c B_VECTOR_ICON_TYPE
190 \return A status code, \c B_OK if everything went fine, an error code
192 \retval B_OK Retrieved the icon successfully.
193 \retval B_BAD_VALUE \a device, \a _data, \a _size, or _type was \c NULL.
200 \fn status_t get_named_icon(const char* name, BBitmap* icon,
202 \brief Get the icon by name, C++ only.
204 \param name The name of the icon to get.
205 \param icon A pointer to a pre-allocated BBitmap of the correct dimension
206 to store the requested icon (16x16 for the mini and 32x32 for the
208 \param which The size of the icon to retrieve. Currently 16
209 (\c B_MINI_ICON) and 32 (\c B_LARGE_ICON) are supported.
211 \return A status code, \c B_OK if everything went fine, an error code
213 \retval B_OK Retrieved the icon successfully.
214 \retval B_BAD_VALUE \a name or \a icon was \c NULL.
221 \fn status_t get_named_icon(const char* name, uint8** _data,
222 size_t* _size, type_code* _type);
223 \brief Get the icon by name, C++ only.
225 \param name The name of the icon to get.
226 \param _data A pointer to a pointer to an array of uint8 pixel data to
228 \param _size The size of the icon to fill out. If vector, it is filled in
229 with the width in pixels, if bitmap, one of the following constants:
232 \param _type The icon type code to fill out, one of the following:
233 - \c B_MINI_ICON_TYPE
234 - \c B_LARGE_ICON_TYPE
235 - \c B_VECTOR_ICON_TYPE
237 \return A status code, \c B_OK if everything went fine, an error code
239 \retval B_OK Retrieved the icon successfully.
240 \retval B_BAD_VALUE \a name, \a _data, \a _size, or \c _type was \c NULL.