| 1162 | namespace detail { |
| 1163 | |
| 1164 | BOOST_FILESYSTEM_DECL void path_algorithms::increment_v3(path_detail::path_iterator& it) |
| 1165 | { |
| 1166 | const size_type size = it.m_path_ptr->m_pathname.size(); |
| 1167 | BOOST_ASSERT_MSG(it.m_pos < size, "path::iterator increment past end()"); |
| 1168 | |
| 1169 | // increment to position past current element; if current element is implicit dot, |
| 1170 | // this will cause m_pos to represent the end iterator |
| 1171 | it.m_pos += it.m_element.m_pathname.size(); |
| 1172 | |
| 1173 | // if the end is reached, we are done |
| 1174 | if (it.m_pos >= size) |
| 1175 | { |
| 1176 | BOOST_ASSERT_MSG(it.m_pos == size, "path::iterator increment after the referenced path was modified"); |
| 1177 | it.m_element.clear(); // aids debugging |
| 1178 | return; |
| 1179 | } |
| 1180 | |
| 1181 | // process separator (Windows drive spec is only case not a separator) |
| 1182 | if (detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos])) |
| 1183 | { |
| 1184 | size_type root_name_size = 0; |
| 1185 | size_type root_dir_pos = find_root_directory_start(it.m_path_ptr->m_pathname.c_str(), size, root_name_size); |
| 1186 | |
| 1187 | // detect root directory and set iterator value to the separator if it is |
| 1188 | if (it.m_pos == root_dir_pos && it.m_element.m_pathname.size() == root_name_size) |
| 1189 | { |
| 1190 | it.m_element.m_pathname = path::separator; // generic format; see docs |
| 1191 | return; |
| 1192 | } |
| 1193 | |
| 1194 | // skip separators until m_pos points to the start of the next element |
| 1195 | while (it.m_pos != size && detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos])) |
| 1196 | { |
| 1197 | ++it.m_pos; |
| 1198 | } |
| 1199 | |
| 1200 | // detect trailing separator, and treat it as ".", per POSIX spec |
| 1201 | if (it.m_pos == size && |
| 1202 | !is_root_separator(it.m_path_ptr->m_pathname, root_dir_pos, it.m_pos - 1)) |
| 1203 | { |
| 1204 | --it.m_pos; |
| 1205 | it.m_element = detail::dot_path(); |
| 1206 | return; |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | // get m_element |
| 1211 | size_type end_pos = it.m_path_ptr->m_pathname.find_first_of(separators, it.m_pos); |
| 1212 | if (end_pos == string_type::npos) |
| 1213 | end_pos = size; |
| 1214 | const path::value_type* p = it.m_path_ptr->m_pathname.c_str(); |
| 1215 | it.m_element.m_pathname.assign(p + it.m_pos, p + end_pos); |
| 1216 | } |
| 1217 | |
| 1218 | BOOST_FILESYSTEM_DECL void path_algorithms::increment_v4(path_detail::path_iterator& it) |
| 1219 | { |
nothing calls this directly
no test coverage detected