diff options
Diffstat (limited to 'src/utils/Mime.h')
-rw-r--r-- | src/utils/Mime.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/utils/Mime.h b/src/utils/Mime.h new file mode 100644 index 0000000000..330b01f55e --- /dev/null +++ b/src/utils/Mime.h @@ -0,0 +1,56 @@ +#pragma once +/* + * Copyright (C) 2012-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <string> +#include <map> + +class CURL; + +class CFileItem; + +class CMime +{ +public: + static std::string GetMimeType(const std::string &extension); + static std::string GetMimeType(const CFileItem &item); + static std::string GetMimeType(const CURL &url, bool lookup = true); + + enum EFileType + { + FileTypeUnknown = 0, + FileTypeHtml, + FileTypeXml, + FileTypePlainText, + FileTypeZip, + FileTypeGZip, + FileTypeRar, + FileTypeBmp, + FileTypeGif, + FileTypePng, + FileTypeJpeg, + }; + static EFileType GetFileTypeFromMime(const std::string& mimeType); + static EFileType GetFileTypeFromContent(const std::string& fileContent); + static bool parseMimeType(const std::string& mimeType, std::string& type, std::string& subtype); + +private: + static std::map<std::string, std::string> m_mimetypes; +}; |