diff --git a/oamapps/mcsadmin/mcsadmin.cpp b/oamapps/mcsadmin/mcsadmin.cpp index c1f42f52c..d53aee795 100644 --- a/oamapps/mcsadmin/mcsadmin.cpp +++ b/oamapps/mcsadmin/mcsadmin.cpp @@ -188,6 +188,9 @@ int main(int argc, char* argv[]) string ccHistoryFile = HOME + "/.cc_history"; + cout << startup::StartUp::installDir(); + cout << startup::StartUp::tmpDir(); + string cf = startup::StartUp::installDir() + "/etc/" + ConsoleCmdsFile; fConfig = Config::makeConfig(cf); diff --git a/utils/startup/installdir.cpp b/utils/startup/installdir.cpp index 5f09a0bd2..c7d2a21c9 100644 --- a/utils/startup/installdir.cpp +++ b/utils/startup/installdir.cpp @@ -71,6 +71,49 @@ const string StartUp::installDir() return *fInstallDirp; } +/* static */ +mutex StartUp::fTmpDirLock; +/* static */ +string* StartUp::fTmpDirp = 0; + +/* static */ +const string StartUp::tmpDir() +{ + mutex::scoped_lock lk(fTmpDirLock); + + if (fTmpDirp) + return *fTmpDirp; + +#ifdef _MSC_VER + fTmpDirp = new string("C:\\Calpont\Tmp"); + string cfStr = IDBreadRegistry(""); + + if (!cfStr.empty()) + *fTmpDirp = cfStr; + +#else + fTmpDirp = new string("/tmp"); + //See if we can figure out the tmp dir in Linux... + //1. env var COLUMNSTORE_INSTALL_DIR + const char* p = 0; + p = getenv("COLUMNSTORE_INSTALL_DIR"); + + if (p && *p) + { + string homedir = "/"; + char* p = getenv("HOME"); + + if (p && *p) + homedir = p; + + *fTmpDirp = homedir + "/tmp"; + } + +#endif + + return *fTmpDirp; +} + } // vim:ts=4 sw=4: diff --git a/utils/startup/installdir.h b/utils/startup/installdir.h index 58d99b061..3df874daa 100644 --- a/utils/startup/installdir.h +++ b/utils/startup/installdir.h @@ -39,6 +39,7 @@ public: ~StartUp() {} static const std::string installDir(); + static const std::string tmpDir(); private: StartUp(const StartUp& rhs); @@ -46,6 +47,8 @@ private: static boost::mutex fInstallDirLock; static std::string* fInstallDirp; + static boost::mutex fTmpDirLock; + static std::string* fTmpDirp; }; }