Mercurial > hg > orthanc
diff Plugins/Include/orthanc/OrthancCPlugin.h @ 2984:db8f360fcb41
OrthancPluginAutodetectMimeType()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 08 Dec 2018 20:59:37 +0100 |
parents | 792a65fdd94b |
children | 9cc3d40e389b |
line wrap: on
line diff
--- a/Plugins/Include/orthanc/OrthancCPlugin.h Sat Dec 08 11:54:14 2018 +0100 +++ b/Plugins/Include/orthanc/OrthancCPlugin.h Sat Dec 08 20:59:37 2018 +0100 @@ -423,7 +423,8 @@ _OrthancPluginService_CallHttpClient2 = 27, _OrthancPluginService_GenerateUuid = 28, _OrthancPluginService_RegisterPrivateDictionaryTag = 29, - + _OrthancPluginService_AutodetectMimeType = 30, + /* Registration of callbacks */ _OrthancPluginService_RegisterRestCallback = 1000, _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, @@ -6468,6 +6469,45 @@ + typedef struct + { + const char** result; + const char* argument; + } _OrthancPluginRetrieveStaticString; + + /** + * @brief Detect the MIME type of a file. + * + * This function returns the MIME type of a file by inspecting its extension. + * + * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). + * @param path Path to the file. + * @return The MIME type. This is a statically-allocated + * string, do not free it. + * @ingroup Toolbox + **/ + ORTHANC_PLUGIN_INLINE const char* OrthancPluginAutodetectMimeType( + OrthancPluginContext* context, + const char* path) + { + const char* result = NULL; + + _OrthancPluginRetrieveStaticString params; + params.result = &result; + params.argument = path; + + if (context->InvokeService(context, _OrthancPluginService_AutodetectMimeType, ¶ms) != OrthancPluginErrorCode_Success) + { + /* Error */ + return NULL; + } + else + { + return result; + } + } + + #ifdef __cplusplus } #endif