From fa508bc933b7d45110be3ab64d193653bd876336 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Mar 2011 09:27:11 +0200 Subject: Add support for database-specific profiles --- odb/profile.cxx | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'odb/profile.cxx') diff --git a/odb/profile.cxx b/odb/profile.cxx index 393c953..fae2490 100644 --- a/odb/profile.cxx +++ b/odb/profile.cxx @@ -13,6 +13,18 @@ using namespace std; + + +static bool +exist (profile_data::path const& p) +{ + struct stat info; + + // Just check that the file exist without checking for permissions, etc. + // + return stat (p.string ().c_str (), &info) == 0 && S_ISREG (info.st_mode); +} + string profile_search (char const* prof, void* arg) { @@ -24,26 +36,30 @@ profile_search (char const* prof, void* arg) path p (prof), odb ("odb"), r; p.normalize (); // Convert '/' to the canonical path separator form. + path p_db (p); + p_db += "-"; + p_db += pd->db.string (); p += ".options"; + p_db += ".options"; - struct stat info; paths::const_iterator i (ps.begin ()), end (ps.end ()); - for (; i != end; ++i) { - // First check in the search directory itself and then try the odb/ - // subdirectory. + // First check for the database-specific version in the search directory + // itself and then try the odb/ subdirectory. // - r = *i / p; + if (exist (r = *i / p_db)) + break; - // Just check that the file exist without checking for permissions, etc. - // - if (stat (r.string ().c_str (), &info) == 0 && S_ISREG (info.st_mode)) + if (exist (r = *i / odb / p_db)) break; - r = *i / odb / p; + // Then try the same with the database-independent version. + // + if (exist (r = *i / p)) + break; - if (stat (r.string ().c_str (), &info) == 0 && S_ISREG (info.st_mode)) + if (exist (r = *i / odb / p)) break; } @@ -60,3 +76,9 @@ profile_search (char const* prof, void* arg) pd->loaded.insert (r); return r.string (); } + +string +profile_search_ignore (char const*, void*) +{ + return string (); +} -- cgit v1.1