diff options
| author | Vincent Richard <[email protected]> | 2004-12-22 09:52:32 +0000 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2004-12-22 09:52:32 +0000 |
| commit | 206b2dafcdd560663b30deac06e10081f397e2c0 (patch) | |
| tree | 8ceb7dcf5a888dbab27b79704d630b959fc852fd /src/utility/path.cpp | |
| parent | Added isParentOf() function. (diff) | |
| download | vmime-206b2dafcdd560663b30deac06e10081f397e2c0.tar.gz vmime-206b2dafcdd560663b30deac06e10081f397e2c0.zip | |
Added renameParent() function.
Diffstat (limited to 'src/utility/path.cpp')
| -rw-r--r-- | src/utility/path.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/utility/path.cpp b/src/utility/path.cpp index 282af12e..24e3c56e 100644 --- a/src/utility/path.cpp +++ b/src/utility/path.cpp @@ -206,6 +206,33 @@ const bool path::isParentOf(const path& p) const } +void path::renameParent(const path& oldPath, const path& newPath) +{ + if (isEmpty() || oldPath.getSize() > getSize()) + return; + + bool equal = true; + list::size_type i; + + for (i = 0 ; equal && i < oldPath.m_list.size() ; ++i) + equal = (m_list[i] == oldPath.m_list[i]); + + if (i != oldPath.m_list.size()) + return; + + list newList; + + for (list::size_type j = 0 ; j < newPath.m_list.size() ; ++j) + newList.push_back(newPath.m_list[j]); + + for (list::size_type j = i ; j < m_list.size() ; ++j) + newList.push_back(m_list[j]); + + m_list.resize(newList.size()); + std::copy(newList.begin(), newList.end(), m_list.begin()); +} + + void path::appendComponent(const path::component& c) { m_list.push_back(c); |
