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

Method find_parent_path_size

src/path.cpp:780–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778}
779
780BOOST_FILESYSTEM_DECL path_algorithms::string_type::size_type path_algorithms::find_parent_path_size(path const& p)
781{
782 const size_type size = p.m_pathname.size();
783 size_type root_name_size = 0;
784 size_type root_dir_pos = find_root_directory_start(p.m_pathname.c_str(), size, root_name_size);
785
786 size_type filename_size = find_filename_size(p.m_pathname, root_name_size, size);
787 size_type end_pos = size - filename_size;
788 while (true)
789 {
790 if (end_pos <= root_name_size)
791 {
792 // Keep the root name as the parent path if there was a filename
793 if (filename_size == 0)
794 end_pos = 0u;
795 break;
796 }
797
798 --end_pos;
799
800 if (!detail::is_directory_separator(p.m_pathname[end_pos]))
801 {
802 ++end_pos;
803 break;
804 }
805
806 if (end_pos == root_dir_pos)
807 {
808 // Keep the trailing root directory if there was a filename
809 end_pos += filename_size > 0;
810 break;
811 }
812 }
813
814 return end_pos;
815}
816
817BOOST_FILESYSTEM_DECL path path_algorithms::filename_v3(path const& p)
818{

Callers

nothing calls this directly

Calls 5

find_filename_sizeFunction · 0.85
is_directory_separatorFunction · 0.85
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected