summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-07-26 22:11:03 +0000
committerChris Wilson <chris+github@qwirx.com>2007-07-26 22:11:03 +0000
commit498e58eb188d98c6ec78e57cdc5f0c211f1f4dcf (patch)
tree4455a5542918955c8f5ade2915d4ae9a6b341093 /lib/common
parent88edb51fc08aa8dfe1fed4c614343d1f2405dac9 (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 'lib/common')
-rw-r--r--lib/common/BoxPortsAndFiles.h23
-rw-r--r--lib/common/Guards.h6
2 files changed, 18 insertions, 11 deletions
diff --git a/lib/common/BoxPortsAndFiles.h b/lib/common/BoxPortsAndFiles.h
index 562c6724..a6ca9f6d 100644
--- a/lib/common/BoxPortsAndFiles.h
+++ b/lib/common/BoxPortsAndFiles.h
@@ -14,20 +14,27 @@
// Backup store daemon
-#define BOX_PORT_BBSTORED (BOX_PORT_BASE+1)
-#define BOX_FILE_BBSTORED_DEFAULT_CONFIG "/etc/box/bbstored.conf"
+#define BOX_PORT_BBSTORED (BOX_PORT_BASE+1)
+
// directory within the RAIDFILE root for the backup store daemon
-#define BOX_RAIDFILE_ROOT_BBSTORED "backup"
+#define BOX_RAIDFILE_ROOT_BBSTORED "backup"
-// Backup client daemon
+// configuration file paths
#ifdef WIN32
-#define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "C:\\Program Files\\Box Backup\\bbackupd.conf"
+ // no default config file path, use these macros to call
+ // GetDefaultConfigFilePath() instead.
+
+ #define BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE \
+ GetDefaultConfigFilePath("bbackupd.conf").c_str()
+ #define BOX_GET_DEFAULT_RAIDFILE_CONFIG_FILE \
+ GetDefaultConfigFilePath("raidfile.conf").c_str()
+ #define BOX_GET_DEFAULT_BBSTORED_CONFIG_FILE \
+ GetDefaultConfigFilePath("bbstored.conf").c_str()
#else
#define BOX_FILE_BBACKUPD_DEFAULT_CONFIG "/etc/box/bbackupd.conf"
-#endif
-
-// RaidFile conf location default
#define BOX_FILE_RAIDFILE_DEFAULT_CONFIG "/etc/box/raidfile.conf"
+#define BOX_FILE_BBSTORED_DEFAULT_CONFIG "/etc/box/bbstored.conf"
+#endif
// Default name of the named pipe
#define BOX_NAMED_PIPE_NAME L"\\\\.\\pipe\\boxbackup"
diff --git a/lib/common/Guards.h b/lib/common/Guards.h
index fbcfedaf..d2fb84e0 100644
--- a/lib/common/Guards.h
+++ b/lib/common/Guards.h
@@ -32,13 +32,13 @@ template <int flags = O_RDONLY | O_BINARY, int mode = (S_IRUSR | S_IWUSR | S_IRG
class FileHandleGuard
{
public:
- FileHandleGuard(const char *filename)
- : mOSFileHandle(::open(filename, flags, mode))
+ FileHandleGuard(const std::string& rFilename)
+ : mOSFileHandle(::open(rFilename.c_str(), flags, mode))
{
if(mOSFileHandle < 0)
{
BOX_ERROR("FileHandleGuard: failed to open file '" <<
- filename << "': " << strerror(errno));
+ rFilename << "': " << strerror(errno));
THROW_EXCEPTION(CommonException, OSFileOpenError)
}
}