Initial checkin. BPrivate::Storage::Mime::AssociatedTypes class, which
is responsible for managing associations between mime types and file extensions. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1146 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file AssociatedTypes.h
|
||||
AssociatedTypes class declarations
|
||||
*/
|
||||
|
||||
#ifndef _MIME_ASSOCIATED_TYPES_H
|
||||
#define _MIME_ASSOCIATED_TYPES_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
class BMessage;
|
||||
class BString;
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
namespace Mime {
|
||||
|
||||
class AssociatedTypes {
|
||||
public:
|
||||
AssociatedTypes();
|
||||
~AssociatedTypes();
|
||||
|
||||
status_t GetAssociatedTypes(const char *extension, BMessage *types);
|
||||
status_t GuessMimeType(const char *filename, BString *result);
|
||||
status_t GuessMimeType(const entry_ref *ref, BString *result);
|
||||
|
||||
status_t SetFileExtensions(const char *type, const BMessage *extensions);
|
||||
status_t DeleteFileExtensions(const char *type);
|
||||
|
||||
void PrintToStream() const;
|
||||
private:
|
||||
status_t AddAssociatedType(const char *extension, const char *type);
|
||||
status_t RemoveAssociatedType(const char *extension, const char *type);
|
||||
|
||||
status_t BuildAssociatedTypesTable();
|
||||
|
||||
status_t ProcessType(const char *type);
|
||||
std::string PrepExtension(const char *extension) const;
|
||||
|
||||
std::map<std::string, std::set<std::string> > fFileExtensions; // mime type => set of associated file extensions
|
||||
std::map<std::string, std::set<std::string> > fAssociatedTypes; // file extension => set of associated mime types
|
||||
|
||||
bool fHaveDoneFullBuild;
|
||||
};
|
||||
|
||||
} // namespace Mime
|
||||
} // namespace Storage
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif // _MIME_ASSOCIATED_TYPES_H
|
||||
Reference in New Issue
Block a user