aboutsummaryrefslogtreecommitdiff
path: root/odb/profile.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-30 09:27:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-30 09:27:11 +0200
commitfa508bc933b7d45110be3ab64d193653bd876336 (patch)
tree1032cfd2d4fba1449040a46a40332e66921a7998 /odb/profile.cxx
parent51529c4c62b00ea681f28b591fdcaa0c670da3d1 (diff)
Add support for database-specific profiles
Diffstat (limited to 'odb/profile.cxx')
-rw-r--r--odb/profile.cxx42
1 files changed, 32 insertions, 10 deletions
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 ();
+}