 <p>The <code>boost::filesystem::recursive_directory_iterator</code> has a <code>path()</code> property that you can query. You can then use the following decomposition methods available for <code>boost::filesystem::path</code> to manually build the path to compare:</p> <pre><code>path root_path() const; path root_name() const; // returns 0 or 1 element path path root_directory() const; // returns 0 or 1 element path path relative_path() const; path parent_path() const; path filename() const; // returns 0 or 1 element path path stem() const; // returns 0 or 1 element path path extension() const; // returns 0 or 1 element path </code></pre> <p>For example you can rollout a version of stripping the root as follows:</p> <pre><code>#include &lt;iostream&gt; #include &lt;boost/filesystem.hpp&gt; boost::filesystem::path strip_root(const boost::filesystem::path&amp; p) { const boost::filesystem::path&amp; parent_path = p.parent_path(); if (parent_path.empty() || parent_path.string() == "/") return boost::filesystem::path(); else return strip_root(parent_path) / p.filename(); } int main() { std::cout &lt;&lt; strip_root("/a") &lt;&lt; std::endl; std::cout &lt;&lt; strip_root("/a/b") &lt;&lt; std::endl; std::cout &lt;&lt; strip_root("/a/b/c") &lt;&lt; std::endl; std::cout &lt;&lt; strip_root("/a/b.dir/c.ext") &lt;&lt; std::endl; } // Output: "" "b" "b/c" "b.dir/c.ext" </code></pre>