MCPcopy Create free account
hub / github.com/boostorg/filesystem / m_path_iterator_increment

Method m_path_iterator_increment

src/path.cpp:692–749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690 }
691
692 void path::m_path_iterator_increment(path::iterator & it)
693 {
694 BOOST_ASSERT_MSG(it.m_pos < it.m_path_ptr->m_pathname.size(),
695 "path::basic_iterator increment past end()");
696
697 // increment to position past current element; if current element is implicit dot,
698 // this will cause it.m_pos to represent the end iterator
699 it.m_pos += it.m_element.m_pathname.size();
700
701 // if the end is reached, we are done
702 if (it.m_pos == it.m_path_ptr->m_pathname.size())
703 {
704 it.m_element.clear(); // aids debugging, may release unneeded memory
705 return;
706 }
707
708 // both POSIX and Windows treat paths that begin with exactly two separators specially
709 bool was_net(it.m_element.m_pathname.size() > 2
710 && is_separator(it.m_element.m_pathname[0])
711 && is_separator(it.m_element.m_pathname[1])
712 && !is_separator(it.m_element.m_pathname[2]));
713
714 // process separator (Windows drive spec is only case not a separator)
715 if (is_separator(it.m_path_ptr->m_pathname[it.m_pos]))
716 {
717 // detect root directory
718 if (was_net
719# ifdef BOOST_WINDOWS_API
720 // case "c:/"
721 || it.m_element.m_pathname[it.m_element.m_pathname.size()-1] == colon
722# endif
723 )
724 {
725 it.m_element.m_pathname = separator; // generic format; see docs
726 return;
727 }
728
729 // skip separators until it.m_pos points to the start of the next element
730 while (it.m_pos != it.m_path_ptr->m_pathname.size()
731 && is_separator(it.m_path_ptr->m_pathname[it.m_pos]))
732 { ++it.m_pos; }
733
734 // detect trailing separator, and treat it as ".", per POSIX spec
735 if (it.m_pos == it.m_path_ptr->m_pathname.size()
736 && !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1))
737 {
738 --it.m_pos;
739 it.m_element = dot_path;
740 return;
741 }
742 }
743
744 // get m_element
745 size_type end_pos(it.m_path_ptr->m_pathname.find_first_of(separators, it.m_pos));
746 if (end_pos == string_type::npos)
747 end_pos = it.m_path_ptr->m_pathname.size();
748 it.m_element = it.m_path_ptr->m_pathname.substr(it.m_pos, end_pos - it.m_pos);
749 }

Callers

nothing calls this directly

Calls 2

is_separatorFunction · 0.85
is_root_separatorFunction · 0.85

Tested by

no test coverage detected