diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-01-17 21:59:13 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-01-17 21:59:13 +0000 |
commit | 5035fdfe9be9ce82d3f6c6affa310e8763d7b102 (patch) | |
tree | 1fdc8af2ee79fc45c452767aa5a9c812fac4c7bc | |
parent | 3dc6cc0f31914aecc0900583dff6c80b00987611 (diff) |
Moved MakeFullPath into its own library file so that we can share it
(BackupQueries needs it too) (refs #3)
-rw-r--r-- | bin/bbackupd/BackupClientDirectoryRecord.cpp | 28 | ||||
-rw-r--r-- | lib/common/PathUtils.cpp | 34 | ||||
-rw-r--r-- | lib/common/PathUtils.h | 26 |
3 files changed, 61 insertions, 27 deletions
diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp index 1cc10d99..43824130 100644 --- a/bin/bbackupd/BackupClientDirectoryRecord.cpp +++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp @@ -29,6 +29,7 @@ #include "BackupDaemon.h" #include "BackupStoreException.h" #include "Archive.h" +#include "PathUtils.h" #include "MemLeakFindOn.h" @@ -97,33 +98,6 @@ void BackupClientDirectoryRecord::DeleteSubDirectories() // -------------------------------------------------------------------------- // // Function -// Name: MakeFullPath(const std::string& rDir, const std::string& rFile) -// Purpose: Combine directory and file name -// Created: 2006/08/10 -// -// -------------------------------------------------------------------------- -static std::string MakeFullPath(const std::string& rDir, - const std::string& rFile) -{ - std::string result; - - if (rDir.size() > 0 && - rDir[rDir.size()-1] == DIRECTORY_SEPARATOR_ASCHAR) - { - result = rDir + rFile; - } - else - { - result = rDir + DIRECTORY_SEPARATOR + rFile; - } - - return result; -} - - -// -------------------------------------------------------------------------- -// -// Function // Name: BackupClientDirectoryRecord::SyncDirectory(BackupClientDirectoryRecord::SyncParams &, int64_t, const std::string &, bool) // Purpose: Syncronise, recusively, a local directory with the server. // Created: 2003/10/08 diff --git a/lib/common/PathUtils.cpp b/lib/common/PathUtils.cpp new file mode 100644 index 00000000..924d47d2 --- /dev/null +++ b/lib/common/PathUtils.cpp @@ -0,0 +1,34 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: PathUtils.cpp +// Purpose: Platform-independent path manipulation +// Created: 2007/01/17 +// +// -------------------------------------------------------------------------- + +#include "Box.h" +#include <string> + +// -------------------------------------------------------------------------- +// +// Function +// Name: MakeFullPath(const std::string& rDir, const std::string& rFile) +// Purpose: Combine directory and file name +// Created: 2006/08/10 +// +// -------------------------------------------------------------------------- +std::string MakeFullPath(const std::string& rDir, const std::string& rEntry) +{ + std::string result(rDir); + + if (result.size() > 0 && + result[result.size()-1] != DIRECTORY_SEPARATOR_ASCHAR) + { + result += DIRECTORY_SEPARATOR; + } + + result += rEntry; + + return result; +} diff --git a/lib/common/PathUtils.h b/lib/common/PathUtils.h new file mode 100644 index 00000000..1cf2e507 --- /dev/null +++ b/lib/common/PathUtils.h @@ -0,0 +1,26 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: PathUtils.h +// Purpose: Platform-independent path manipulation +// Created: 2007/01/17 +// +// -------------------------------------------------------------------------- + +#ifndef PATHUTILS_H +#define PATHUTILS_H + +#include <string> + +// -------------------------------------------------------------------------- +// +// Function +// Name: MakeFullPath(const std::string& rDir, const std::string& rFile) +// Purpose: Combine directory and file name +// Created: 2006/08/10 +// +// -------------------------------------------------------------------------- + +std::string MakeFullPath(const std::string& rDir, const std::string& rEntry); + +#endif // !PATHUTILS_H |