Support multiple MIME DB directories

Each installation location (system, common, common/non-packaged,
~/config, ~/config/non-package) can now have a read-only data/mime_db
directory. ~/config/settings/beos_mime is now named mime_db as well. The
contents of all directories makes up the MIME DB. Entries in more
specific locations shadow entries in more general locations. Only the
directory in ~/config/settings is where the registrar writes changes to.

The new layout allows packages to contribute entries to the MIME DB by
simply providing the respective files in data/mime_db. Consequently the
user settings directory is supposed to contain only the things the user
has actually changed.

Seems to work fine as far as tested. A few issues, though:
* The registrar doesn't monitor the directories yet, so it doesn't
  notice entry changes due to package de-/activation.
* ATM it is not possible to remove a MIME type that is not in the user
  settings directory, although the FileTypes GUI suggests that it is.
  We'd have to work with white-outs, since we cannot remove the files in
  the data/mime_db directories. Or, alternatively, the API has to be
  extended and the FileTypes GUI adjusted to disable the "Remove" button
  in such a case.
This commit is contained in:
Ingo Weinhold
2013-05-07 04:43:51 +02:00
parent 38e3973ecf
commit 59a653b51c
10 changed files with 367 additions and 120 deletions
@@ -7,12 +7,12 @@
#include <StorageDefs.h>
#include <String.h>
#include <string>
class BNode;
class BMessage;
class BString;
class BStringList;
namespace BPrivate {
@@ -20,8 +20,8 @@ namespace Storage {
namespace Mime {
// Database directory
const std::string get_database_directory();
const std::string get_application_database_directory();
const BStringList& get_database_directories();
BString get_writable_database_directory();
// Attribute Prefixes
extern const char *kMiniIconAttrPrefix;
@@ -75,7 +75,7 @@ extern const char *kMetaMimeType;
// Error codes (to be used only by BPrivate::Storage::Mime members)
extern const status_t kMimeGuessFailureError;
std::string type_to_filename(const char *type);
BString type_to_writable_filename(const char *type);
status_t open_type(const char *type, BNode *result);
status_t open_or_create_type(const char *type, BNode *result, bool *didCreate);