Added renameParent() function.
This commit is contained in:
parent
8eacc34869
commit
206b2dafcd
@ -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)
|
void path::appendComponent(const path::component& c)
|
||||||
{
|
{
|
||||||
m_list.push_back(c);
|
m_list.push_back(c);
|
||||||
|
@ -139,6 +139,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
const bool isParentOf(const path& p) const;
|
const bool isParentOf(const path& p) const;
|
||||||
|
|
||||||
|
/** Rename a parent component in the path.
|
||||||
|
*
|
||||||
|
* @param oldPath old parent path
|
||||||
|
* @param newPath new parent path
|
||||||
|
*/
|
||||||
|
void renameParent(const path& oldPath, const path& newPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
list m_list;
|
list m_list;
|
||||||
|
Loading…
Reference in New Issue
Block a user