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

Method generic_path_v4

src/path.cpp:446–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444}
445
446BOOST_FILESYSTEM_DECL path path_algorithms::generic_path_v4(path const& p)
447{
448 path tmp;
449 const size_type pathname_size = p.m_pathname.size();
450 tmp.m_pathname.reserve(pathname_size);
451
452 const value_type* const pathname = p.m_pathname.c_str();
453
454 // Treat root name specially as it may contain backslashes, duplicate ones too,
455 // in case of UNC paths and Windows-specific prefixes.
456 size_type root_name_size = 0u;
457 size_type root_dir_pos = find_root_directory_start(pathname, pathname_size, root_name_size);
458 if (root_name_size > 0u)
459 tmp.m_pathname.append(pathname, root_name_size);
460
461 size_type pos = root_name_size;
462 if (root_dir_pos < pathname_size)
463 {
464 tmp.m_pathname.push_back(path::separator);
465 pos = root_dir_pos + 1u;
466 }
467
468 while (pos < pathname_size)
469 {
470 size_type element_size = find_separator(pathname + pos, pathname_size - pos);
471 if (element_size > 0u)
472 {
473 tmp.m_pathname.append(pathname + pos, element_size);
474
475 pos += element_size;
476 if (pos >= pathname_size)
477 break;
478
479 tmp.m_pathname.push_back(path::separator);
480 }
481
482 ++pos;
483 }
484
485 return tmp;
486}
487
488#if defined(BOOST_FILESYSTEM_WINDOWS_API)
489

Callers

nothing calls this directly

Calls 4

find_separatorFunction · 0.85
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected