diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-10 02:36:40 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-10 02:36:40 +0000 |
commit | 52cd682405f7a052d45d83b66cc75f19316ceffe (patch) | |
tree | 6b76eeddb2d4682db61f8e38462413bc40b59a3d /sca-cpp/trunk/components | |
parent | 629c1f267e5f7a835891e36ebdae8404740f13e2 (diff) |
Enable multiple apps to co-exist under different paths in a single Virtual Host and Internet domain.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1200105 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/components')
-rw-r--r-- | sca-cpp/trunk/components/constdb/tinycdb.hpp | 14 | ||||
-rw-r--r-- | sca-cpp/trunk/components/filedb/filedb.cpp | 3 | ||||
-rw-r--r-- | sca-cpp/trunk/components/filedb/filedb.hpp | 14 | ||||
-rw-r--r-- | sca-cpp/trunk/components/kvdb/leveldb.hpp | 14 |
4 files changed, 41 insertions, 4 deletions
diff --git a/sca-cpp/trunk/components/constdb/tinycdb.hpp b/sca-cpp/trunk/components/constdb/tinycdb.hpp index e26001dc59..514133b0e1 100644 --- a/sca-cpp/trunk/components/constdb/tinycdb.hpp +++ b/sca-cpp/trunk/components/constdb/tinycdb.hpp @@ -90,6 +90,18 @@ const bool free(const buffer&b) { } /** + * Convert a database name to an absolute path. + */ +const string absdbname(const string& name) { + if (length(name) == 0 || c_str(name)[0] == '/') + return name; + char cwd[512]; + if (getcwd(cwd, sizeof(cwd)) == NULL) + return name; + return string(cwd) + "/" + name; +} + +/** * Represents a TinyCDB connection. */ class TinyCDB { @@ -99,7 +111,7 @@ public: st.st_ino = 0; } - TinyCDB(const string& name) : owner(true), name(name), fd(-1) { + TinyCDB(const string& name) : owner(true), name(absdbname(name)), fd(-1) { debug(name, "tinycdb::tinycdb::name"); st.st_ino = 0; } diff --git a/sca-cpp/trunk/components/filedb/filedb.cpp b/sca-cpp/trunk/components/filedb/filedb.cpp index 473dfea281..5f755de3eb 100644 --- a/sca-cpp/trunk/components/filedb/filedb.cpp +++ b/sca-cpp/trunk/components/filedb/filedb.cpp @@ -103,7 +103,8 @@ const failable<value> start(const list<value>& params) { // Connect to the configured database and table const value dbname = ((lambda<value(list<value>)>)car(params))(list<value>()); const value format = ((lambda<value(list<value>)>)cadr(params))(list<value>()); - filedb::FileDB& db = *(new (gc_new<filedb::FileDB>()) filedb::FileDB(dbname, format)); + + filedb::FileDB& db = *(new (gc_new<filedb::FileDB>()) filedb::FileDB(absdbname(dbname), format)); // Return the component implementation lambda function return value(lambda<value(const list<value>&)>(applyfiledb(db))); diff --git a/sca-cpp/trunk/components/filedb/filedb.hpp b/sca-cpp/trunk/components/filedb/filedb.hpp index d2bc8bd212..993003ce8e 100644 --- a/sca-cpp/trunk/components/filedb/filedb.hpp +++ b/sca-cpp/trunk/components/filedb/filedb.hpp @@ -40,6 +40,18 @@ namespace tuscany { namespace filedb { /** + * Convert a database name to an absolute path. + */ +const string absdbname(const string& name) { + if (length(name) == 0 || c_str(name)[0] == '/') + return name; + char cwd[512]; + if (getcwd(cwd, sizeof(cwd)) == NULL) + return name; + return string(cwd) + "/" + name; +} + +/** * Represents a FileDB connection. */ class FileDB { @@ -48,7 +60,7 @@ public: debug("filedb::filedb"); } - FileDB(const string& name, const string& format) : owner(true), name(name), format(format) { + FileDB(const string& name, const string& format) : owner(true), name(absdbname(name)), format(format) { debug(name, "filedb::filedb::name"); debug(format, "filedb::filedb::format"); } diff --git a/sca-cpp/trunk/components/kvdb/leveldb.hpp b/sca-cpp/trunk/components/kvdb/leveldb.hpp index 893166c361..96e404a6e4 100644 --- a/sca-cpp/trunk/components/kvdb/leveldb.hpp +++ b/sca-cpp/trunk/components/kvdb/leveldb.hpp @@ -90,6 +90,18 @@ const bool free(const buffer&b) { } /** + * Convert a database name to an absolute path. + */ +const string absdbname(const string& name) { + if (length(name) == 0 || c_str(name)[0] == '/') + return name; + char cwd[512]; + if (getcwd(cwd, sizeof(cwd)) == NULL) + return name; + return string(cwd) + "/" + name; +} + +/** * Represents a LevelDB connection. */ class LevelDB { @@ -99,7 +111,7 @@ public: st.st_ino = 0; } - LevelDB(const string& name) : owner(true), name(name), fd(-1) { + LevelDB(const string& name) : owner(true), name(absdbname(name)), fd(-1) { debug(name, "leveldb::leveldb::name"); st.st_ino = 0; } |