The MIME Type API provides functions to map MIME types to file extensions and vice versa.
Required Header
#include <mime_type.h>
Overview
The MIME Type API provides functions to map MIME types to file extensions and vice versa. Conversions are provided from file extensions to MIME types and from MIME types to file extensions.
Note that some MIME types have multiple file extensions or no extension, and the MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
Enumeration Type Documentation
Enumeration of error code.
- Enumerator:
MIME_TYPE_ERROR_NONE |
Successful
|
MIME_TYPE_ERROR_INVALID_PARAMETER |
Invalid parameter
|
MIME_TYPE_ERROR_OUT_OF_MEMORY |
Out of memory
|
MIME_TYPE_ERROR_IO_ERROR |
Internal I/O error
|
MIME_TYPE_ERROR_PERMISSION_DENIED |
No access for the file (Since 4.0)
|
Function Documentation
Gets the file extensions for the given MIME type.
- Parameters:
-
[in] | mime_type | The MIME type |
[out] | file_extension | The array of file extension without the leading dot ('.') |
[out] | length | The length of the array of file extension or zero if there is none |
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
- See also:
- mime_type_get_mime_type()
Gets the MIME type for the given file extension.
- Parameters:
-
[in] | file_extension | The file extension without the leading dot ('.') |
[out] | mime_type | The MIME type for the given file extension
The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats |
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
- See also:
- mime_type_get_file_extension()
Gets the MIME type for the given data.
- Since :
- 4.0
- Parameters:
-
[in] | data | The stream of file data |
[in] | len | The length of data |
[out] | mime_type | The MIME type for the given file extension
The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats |
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
Gets the MIME type for the given file path.
- Since :
- 4.0
- Parameters:
-
[in] | file_path | The path of target file |
[out] | mime_type | The MIME type for the given file extension
The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats |
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-