btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / storage / mime / DatabaseLocation.h
blob69b342452d8f1ea8516ad35fd27f9d768564c017
1 /*
2 * Copyright 2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
7 */
8 #ifndef _MIME_DATABASE_LOCATION_H
9 #define _MIME_DATABASE_LOCATION_H
12 #include <Mime.h>
13 #include <StringList.h>
16 namespace BPrivate {
17 namespace Storage {
18 namespace Mime {
21 class DatabaseLocation {
22 public:
23 DatabaseLocation();
24 ~DatabaseLocation();
26 bool AddDirectory(const BString& directory);
28 // paths
30 const BStringList& Directories() const
31 { return fDirectories; }
32 BString WritableDirectory() const
33 { return fDirectories.StringAt(0); }
35 BString WritablePathForType(const char* type) const
36 { return _TypeToFilename(type, 0); }
38 // opening type nodes
40 status_t OpenType(const char* type, BNode& _node) const;
41 status_t OpenWritableType(const char* type,
42 BNode& _node, bool create,
43 bool* _didCreate = NULL) const;
45 // generic type attributes access
47 ssize_t ReadAttribute(const char* type,
48 const char* attribute, void* data,
49 size_t length, type_code datatype) const;
50 status_t ReadMessageAttribute(const char* type,
51 const char* attribute, BMessage& _message)
52 const;
53 status_t ReadStringAttribute(const char* type,
54 const char* attribute, BString& _string)
55 const;
57 status_t WriteAttribute(const char* type,
58 const char* attribute, const void* data,
59 size_t length, type_code datatype,
60 bool* _didCreate) const;
61 status_t WriteMessageAttribute(const char* type,
62 const char* attribute,
63 const BMessage& message, bool* _didCreate)
64 const;
66 status_t DeleteAttribute(const char* type,
67 const char* attribute) const;
69 // type attribute convenience getters
71 status_t GetAppHint(const char* type, entry_ref& _ref);
72 status_t GetAttributesInfo(const char* type,
73 BMessage& _info);
74 status_t GetShortDescription(const char* type,
75 char* description);
76 status_t GetLongDescription(const char* type,
77 char* description);
78 status_t GetFileExtensions(const char* type,
79 BMessage& _extensions);
80 status_t GetIcon(const char* type, BBitmap& _icon,
81 icon_size size);
82 status_t GetIcon(const char* type, uint8*& _data,
83 size_t& _size);
84 status_t GetIconForType(const char* type,
85 const char* fileType, BBitmap& _icon,
86 icon_size which);
87 status_t GetIconForType(const char* type,
88 const char* fileType, uint8*& _data,
89 size_t& _size);
90 status_t GetPreferredApp(const char* type,
91 char* signature, app_verb verb);
92 status_t GetSnifferRule(const char* type,
93 BString& _result);
94 status_t GetSupportedTypes(const char* type,
95 BMessage& _types);
97 bool IsInstalled(const char* type);
99 private:
100 BString _TypeToFilename(const char* type, int32 index)
101 const;
102 status_t _OpenType(const char* type, BNode& _node,
103 int32& _index) const;
104 status_t _CreateTypeNode(const char* type, BNode& _node)
105 const;
106 status_t _CopyTypeNode(BNode& source, const char* type,
107 BNode& _target) const;
109 private:
110 BStringList fDirectories;
114 } // namespace Mime
115 } // namespace Storage
116 } // namespace BPrivate
119 #endif // _MIME_DATABASE_LOCATION_H