aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2004-12-22 09:15:15 +0000
committerVincent Richard <[email protected]>2004-12-22 09:15:15 +0000
commit8eacc3486914571de3ca1f5d74891c8a9198e656 (patch)
tree29adb63ff8b461ed7faa776a61f61f9e5e1f9732
parentNotification when renaming IMAP folder. (diff)
downloadvmime-8eacc3486914571de3ca1f5d74891c8a9198e656.tar.gz
vmime-8eacc3486914571de3ca1f5d74891c8a9198e656.zip
Added isParentOf() function.
-rw-r--r--src/utility/path.cpp14
-rw-r--r--src/utility/path.hpp10
2 files changed, 23 insertions, 1 deletions
diff --git a/src/utility/path.cpp b/src/utility/path.cpp
index 76a938e3..282af12e 100644
--- a/src/utility/path.cpp
+++ b/src/utility/path.cpp
@@ -192,6 +192,20 @@ const bool path::isDirectParentOf(const path& p) const
}
+const bool path::isParentOf(const path& p) const
+{
+ if (p.getSize() < getSize() + 1)
+ return (false);
+
+ bool equal = true;
+
+ for (list::size_type i = 0 ; equal && i < m_list.size() ; ++i)
+ equal = (m_list[i] == p.m_list[i]);
+
+ return (equal);
+}
+
+
void path::appendComponent(const path::component& c)
{
m_list.push_back(c);
diff --git a/src/utility/path.hpp b/src/utility/path.hpp
index 83bd186a..933794f1 100644
--- a/src/utility/path.hpp
+++ b/src/utility/path.hpp
@@ -126,10 +126,18 @@ public:
/** Test whether this path is a direct parent of another one.
*
* @param p other path
+ * @return true if the specified path is a child
+ * of this path, false otherwise
+ */
+ const bool isDirectParentOf(const path& p) const;
+
+ /** Test whether this path is a parent of another one.
+ *
+ * @param p other path
* @return true if the specified path is a child (direct or
* indirect) of this path, false otherwise
*/
- const bool isDirectParentOf(const path& p) const;
+ const bool isParentOf(const path& p) const;
private: