From 45c3a5cfa9a61e479761bff834e866910effd4f6 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 18 Jan 2005 01:13:13 +0000 Subject: [PATCH] Obtain user settings dir path via find_directory() now. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10814 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/mime/database_support.cpp | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/kits/storage/mime/database_support.cpp b/src/kits/storage/mime/database_support.cpp index 1ef90f2ee7..84f2845fd0 100644 --- a/src/kits/storage/mime/database_support.cpp +++ b/src/kits/storage/mime/database_support.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -38,12 +39,17 @@ namespace BPrivate { namespace Storage { namespace Mime { -static const char *sHaikuDBDir = "/boot/home/config/settings/beos_mime"; +static const char *get_user_settings_dir(BPath &path); + +static BPath sSettingsDirPath; +static const std::string sSettingsDir = get_user_settings_dir(sSettingsDirPath); + +static const char *sHaikuDBDirName = "beos_mime"; // when running natively under Haiku -static const char *sBeOSDBDir = "/boot/home/config/settings/obos_mime"; +static const char *sBeOSDBDirName = "obos_mime"; // when running under BeOS -const std::string kDatabaseDir - = (is_running_on_haiku() ? sHaikuDBDir : sBeOSDBDir); +const std::string kDatabaseDir = sSettingsDir + "/" + + (is_running_on_haiku() ? sHaikuDBDirName : sBeOSDBDirName); const std::string kApplicationDatabaseDir = kDatabaseDir + "/application"; #define ATTR_PREFIX "META:" @@ -98,6 +104,21 @@ const char *kMetaMimeType = "application/x-vnd.Be-meta-mime"; // Error codes const status_t kMimeGuessFailureError = B_ERRORS_END+1; +// get_settings_dir +/*! \brief Sets the supplied BPath to the user settings directory and returns + it as C string. + \param path BPath to be set to the user settings path. + \return the user settings path as C string (\code path.Path() \endcode). +*/ +static +const char* +get_user_settings_dir(BPath &path) +{ + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) + path.SetTo("/boot/home/config/settings"); + return path.Path(); +} + // type_to_filename //! Converts the given MIME type to an absolute path in the MIME database. std::string