| 1216 | } |
| 1217 | |
| 1218 | BOOST_FILESYSTEM_DECL void path_algorithms::increment_v4(path_detail::path_iterator& it) |
| 1219 | { |
| 1220 | const size_type size = it.m_path_ptr->m_pathname.size(); |
| 1221 | BOOST_ASSERT_MSG(it.m_pos <= size, "path::iterator increment past end()"); |
| 1222 | |
| 1223 | if (it.m_element.m_pathname.empty() && (it.m_pos + 1) == size && detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos])) |
| 1224 | { |
| 1225 | // The iterator was pointing to the last empty element of the path; set to end. |
| 1226 | it.m_pos = size; |
| 1227 | return; |
| 1228 | } |
| 1229 | |
| 1230 | // increment to position past current element; if current element is implicit dot, |
| 1231 | // this will cause m_pos to represent the end iterator |
| 1232 | it.m_pos += it.m_element.m_pathname.size(); |
| 1233 | |
| 1234 | // if the end is reached, we are done |
| 1235 | if (it.m_pos >= size) |
| 1236 | { |
| 1237 | BOOST_ASSERT_MSG(it.m_pos == size, "path::iterator increment after the referenced path was modified"); |
| 1238 | it.m_element.clear(); // aids debugging |
| 1239 | return; |
| 1240 | } |
| 1241 | |
| 1242 | // process separator (Windows drive spec is only case not a separator) |
| 1243 | if (detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos])) |
| 1244 | { |
| 1245 | size_type root_name_size = 0; |
| 1246 | size_type root_dir_pos = find_root_directory_start(it.m_path_ptr->m_pathname.c_str(), size, root_name_size); |
| 1247 | |
| 1248 | // detect root directory and set iterator value to the separator if it is |
| 1249 | if (it.m_pos == root_dir_pos && it.m_element.m_pathname.size() == root_name_size) |
| 1250 | { |
| 1251 | it.m_element.m_pathname = path::separator; // generic format; see docs |
| 1252 | return; |
| 1253 | } |
| 1254 | |
| 1255 | // skip separators until m_pos points to the start of the next element |
| 1256 | while (it.m_pos != size && detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos])) |
| 1257 | { |
| 1258 | ++it.m_pos; |
| 1259 | } |
| 1260 | |
| 1261 | // detect trailing separator |
| 1262 | if (it.m_pos == size && |
| 1263 | !is_root_separator(it.m_path_ptr->m_pathname, root_dir_pos, it.m_pos - 1)) |
| 1264 | { |
| 1265 | --it.m_pos; |
| 1266 | it.m_element.m_pathname.clear(); |
| 1267 | return; |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | // get m_element |
| 1272 | size_type end_pos = it.m_path_ptr->m_pathname.find_first_of(separators, it.m_pos); |
| 1273 | if (end_pos == string_type::npos) |
| 1274 | end_pos = size; |
| 1275 | const path::value_type* p = it.m_path_ptr->m_pathname.c_str(); |
nothing calls this directly
no test coverage detected