| 1337 | } |
| 1338 | |
| 1339 | BOOST_FILESYSTEM_DECL void path_algorithms::decrement_v4(path_detail::path_iterator& it) |
| 1340 | { |
| 1341 | const size_type size = it.m_path_ptr->m_pathname.size(); |
| 1342 | BOOST_ASSERT_MSG(it.m_pos > 0, "path::iterator decrement past begin()"); |
| 1343 | BOOST_ASSERT_MSG(it.m_pos <= size, "path::iterator decrement after the referenced path was modified"); |
| 1344 | |
| 1345 | size_type root_name_size = 0; |
| 1346 | size_type root_dir_pos = find_root_directory_start(it.m_path_ptr->m_pathname.c_str(), size, root_name_size); |
| 1347 | |
| 1348 | if (root_dir_pos < size && it.m_pos == root_dir_pos) |
| 1349 | { |
| 1350 | // Was pointing at root directory, decrement to root name |
| 1351 | set_to_root_name: |
| 1352 | it.m_pos = 0u; |
| 1353 | const path::value_type* p = it.m_path_ptr->m_pathname.c_str(); |
| 1354 | it.m_element.m_pathname.assign(p, p + root_name_size); |
| 1355 | return; |
| 1356 | } |
| 1357 | |
| 1358 | // if at end and there was a trailing '/', return "" |
| 1359 | if (it.m_pos == size && |
| 1360 | size > 1 && |
| 1361 | detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos - 1]) && |
| 1362 | !is_root_separator(it.m_path_ptr->m_pathname, root_dir_pos, it.m_pos - 1)) |
| 1363 | { |
| 1364 | --it.m_pos; |
| 1365 | it.m_element.m_pathname.clear(); |
| 1366 | return; |
| 1367 | } |
| 1368 | |
| 1369 | // skip separators unless root directory |
| 1370 | size_type end_pos = it.m_pos; |
| 1371 | while (end_pos > root_name_size) |
| 1372 | { |
| 1373 | --end_pos; |
| 1374 | |
| 1375 | if (end_pos == root_dir_pos) |
| 1376 | { |
| 1377 | // Decremented to the root directory |
| 1378 | it.m_pos = end_pos; |
| 1379 | it.m_element.m_pathname = path::separator; // generic format; see docs |
| 1380 | return; |
| 1381 | } |
| 1382 | |
| 1383 | if (!detail::is_directory_separator(it.m_path_ptr->m_pathname[end_pos])) |
| 1384 | { |
| 1385 | ++end_pos; |
| 1386 | break; |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | if (end_pos <= root_name_size) |
| 1391 | goto set_to_root_name; |
| 1392 | |
| 1393 | size_type filename_size = find_filename_size(it.m_path_ptr->m_pathname, root_name_size, end_pos); |
| 1394 | it.m_pos = end_pos - filename_size; |
| 1395 | const path::value_type* p = it.m_path_ptr->m_pathname.c_str(); |
| 1396 | it.m_element.m_pathname.assign(p + it.m_pos, p + end_pos); |
nothing calls this directly
no test coverage detected