From 498e58eb188d98c6ec78e57cdc5f0c211f1f4dcf Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 26 Jul 2007 22:11:03 +0000 Subject: Make Configuration take a std::string filename instead of a char array, in C++ style. Add a function to get default config file paths at runtime, dependent on the location of the executable being run. Pass the config file name directly to Daemon::Main, instead of faking argv. No default raid file path at compile time on Windows, depends on executable location when run. Determine RaidFile path at runtime if not supplied in config file on Windows. Don't define default locations for config files at compile time on Windows, provide macros to determine them at runtime instead. Make FileHandleGuard take a std::string instead of a char array, C++ style. Determine config file location at runtime instead of hard-coding on Windows. Thanks to Paul MacKenzie, Per Thomsen, Pete Jalajas, Stuart Sanders, Dave Bamford and Gary for pushing me to do this. (fixes #12) Determine config file path at runtime. Call Daemon::Main with config file name instead of building fake argv. (refs #3, merges [1684] [1685] [1686] [1687] [1688] [1689] [1690] [1691] [1692]) --- bin/bbstored/BackupStoreDaemon.cpp | 18 +++++++++++++++++- bin/bbstored/bbstored.cpp | 9 ++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'bin/bbstored') diff --git a/bin/bbstored/BackupStoreDaemon.cpp b/bin/bbstored/BackupStoreDaemon.cpp index c9601575..049c0ae4 100644 --- a/bin/bbstored/BackupStoreDaemon.cpp +++ b/bin/bbstored/BackupStoreDaemon.cpp @@ -132,7 +132,23 @@ void BackupStoreDaemon::SetupInInitialProcess() // Initialise the raid files controller RaidFileController &rcontroller = RaidFileController::GetController(); - rcontroller.Initialise(config.GetKeyValue("RaidFileConf").c_str()); + + std::string raidFileConfig; + + #ifdef WIN32 + if (!config.KeyExists("RaidFileConf")) + { + raidFileConfig = BOX_GET_DEFAULT_RAIDFILE_CONFIG_FILE; + } + else + { + raidFileConfig = config.GetKeyValue("RaidFileConf"); + } + #else + raidFileConfig = config.GetKeyValue("RaidFileConf"); + #endif + + rcontroller.Initialise(raidFileConfig); // Load the account database std::auto_ptr pdb(BackupStoreAccountDatabase::Read(config.GetKeyValue("AccountDatabase").c_str())); diff --git a/bin/bbstored/bbstored.cpp b/bin/bbstored/bbstored.cpp index c0ea1199..54858dd4 100644 --- a/bin/bbstored/bbstored.cpp +++ b/bin/bbstored/bbstored.cpp @@ -23,7 +23,14 @@ int main(int argc, const char *argv[]) Logging::ToSyslog (true); BackupStoreDaemon daemon; - return daemon.Main(BOX_FILE_BBSTORED_DEFAULT_CONFIG, argc, argv); + + #ifdef WIN32 + return daemon.Main(BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE, + argc, argv); + #else + return daemon.Main(BOX_FILE_BBSTORED_DEFAULT_CONFIG, + argc, argv); + #endif MAINHELPER_END } -- cgit v1.2.3