diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-07-26 22:11:03 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-07-26 22:11:03 +0000 |
commit | 498e58eb188d98c6ec78e57cdc5f0c211f1f4dcf (patch) | |
tree | 4455a5542918955c8f5ade2915d4ae9a6b341093 /bin/bbackupd | |
parent | 88edb51fc08aa8dfe1fed4c614343d1f2405dac9 (diff) |
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])
Diffstat (limited to 'bin/bbackupd')
-rw-r--r-- | bin/bbackupd/Win32BackupService.cpp | 26 | ||||
-rw-r--r-- | bin/bbackupd/bbackupd.cpp | 2 |
2 files changed, 10 insertions, 18 deletions
diff --git a/bin/bbackupd/Win32BackupService.cpp b/bin/bbackupd/Win32BackupService.cpp index 7cbf4828..1470b42d 100644 --- a/bin/bbackupd/Win32BackupService.cpp +++ b/bin/bbackupd/Win32BackupService.cpp @@ -29,31 +29,23 @@ void TerminateService(void) DWORD Win32BackupService::WinService(const char* pConfigFileName) { - char exepath[MAX_PATH]; - GetModuleFileName(NULL, exepath, sizeof(exepath)); + DWORD ret; + + // keep MAINHELPER_START happy + int argc = 0; + char* argv[] = {NULL}; + + MAINHELPER_START - std::string configfile; - if (pConfigFileName != NULL) { - configfile = pConfigFileName; + ret = this->Main(pConfigFileName); } else { - // make the default config file name, - // based on the program path - configfile = exepath; - configfile = configfile.substr(0, - configfile.rfind(DIRECTORY_SEPARATOR_ASCHAR)); - configfile += DIRECTORY_SEPARATOR "bbackupd.conf"; + ret = this->Main(BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE); } - const char *argv[] = {exepath, "-c", configfile.c_str()}; - int argc = sizeof(argv) / sizeof(*argv); - DWORD ret; - - MAINHELPER_START - ret = this->Main(BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); MAINHELPER_END return ret; diff --git a/bin/bbackupd/bbackupd.cpp b/bin/bbackupd/bbackupd.cpp index f7091140..b8c8f61a 100644 --- a/bin/bbackupd/bbackupd.cpp +++ b/bin/bbackupd/bbackupd.cpp @@ -89,7 +89,7 @@ int main(int argc, const char *argv[]) else { ExitCode = gpDaemonService->Main( - BOX_FILE_BBACKUPD_DEFAULT_CONFIG, argc, argv); + BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE, argc, argv); } delete gpDaemonService; |