]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/filesystem/src/path.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / filesystem / src / path.cpp
index dcef9d02afac84a93bba7bb51641c07b62d4e4fb..a4588654bad3be0cf88dfc725c8e756782dc76e3 100644 (file)
@@ -73,12 +73,10 @@ namespace
 
 # ifdef BOOST_WINDOWS_API
 
-  const wchar_t separator = L'/';
   const wchar_t* const separators = L"/\\";
   const wchar_t* separator_string = L"/";
   const wchar_t* preferred_separator_string = L"\\";
   const wchar_t colon = L':';
-  const wchar_t dot = L'.';
   const wchar_t questionmark = L'?';
 
   inline bool is_letter(wchar_t c)
@@ -88,23 +86,12 @@ namespace
 
 # else
 
-  const char separator = '/';
   const char* const separators = "/";
   const char* separator_string = "/";
   const char* preferred_separator_string = "/";
-  const char dot = '.';
 
 # endif
 
-  inline bool is_separator(fs::path::value_type c)
-  {
-    return c == separator
-#     ifdef BOOST_WINDOWS_API
-      || c == path::preferred_separator
-#     endif
-      ;
-  }
-
   bool is_root_separator(const string_type& str, size_type pos);
     // pos is position of the separator
 
@@ -145,13 +132,13 @@ namespace filesystem
     if (this == &p)  // self-append
     {
       path rhs(p);
-      if (!is_separator(rhs.m_pathname[0]))
+      if (!detail::is_directory_separator(rhs.m_pathname[0]))
         m_append_separator_if_needed();
       m_pathname += rhs.m_pathname;
     }
     else
     {
-      if (!is_separator(*p.m_pathname.begin()))
+      if (!detail::is_directory_separator(*p.m_pathname.begin()))
         m_append_separator_if_needed();
       m_pathname += p.m_pathname;
     }
@@ -166,13 +153,13 @@ namespace filesystem
       && ptr < m_pathname.data() + m_pathname.size())  // overlapping source
     {
       path rhs(ptr);
-      if (!is_separator(rhs.m_pathname[0]))
+      if (!detail::is_directory_separator(rhs.m_pathname[0]))
         m_append_separator_if_needed();
       m_pathname += rhs.m_pathname;
     }
     else
     {
-      if (!is_separator(*ptr))
+      if (!detail::is_directory_separator(*ptr))
         m_append_separator_if_needed();
       m_pathname += ptr;
     }
@@ -217,7 +204,7 @@ namespace filesystem
 #     ifdef BOOST_WINDOWS_API
       *(m_pathname.end()-1) != colon && 
 #     endif
-      !is_separator(*(m_pathname.end()-1)))
+      !detail::is_directory_separator(*(m_pathname.end()-1)))
     {
       string_type::size_type tmp(m_pathname.size());
       m_pathname += preferred_separator;
@@ -257,7 +244,8 @@ namespace filesystem
 
   path&  path::remove_trailing_separator()
   {
-    if (!m_pathname.empty() && is_separator(m_pathname[m_pathname.size() - 1]))
+    if (!m_pathname.empty()
+      && detail::is_directory_separator(m_pathname[m_pathname.size() - 1]))
       m_pathname.erase(m_pathname.size() - 1);
     return *this;
   }
@@ -294,8 +282,8 @@ namespace filesystem
     return (itr.m_pos != m_pathname.size()
       && (
           (itr.m_element.m_pathname.size() > 1
-            && is_separator(itr.m_element.m_pathname[0])
-            && is_separator(itr.m_element.m_pathname[1])
+            && detail::is_directory_separator(itr.m_element.m_pathname[0])
+            && detail::is_directory_separator(itr.m_element.m_pathname[1])
    )
 #       ifdef BOOST_WINDOWS_API
         || itr.m_element.m_pathname[itr.m_element.m_pathname.size()-1] == colon
@@ -319,7 +307,7 @@ namespace filesystem
     iterator itr(begin());
 
     for (; itr.m_pos != m_pathname.size()
-      && (is_separator(itr.m_element.m_pathname[0])
+      && (detail::is_directory_separator(itr.m_element.m_pathname[0])
 #     ifdef BOOST_WINDOWS_API
       || itr.m_element.m_pathname[itr.m_element.m_pathname.size()-1] == colon
 #     endif
@@ -333,14 +321,14 @@ namespace filesystem
     size_type end_pos(filename_pos(m_pathname, m_pathname.size()));
 
     bool filename_was_separator(m_pathname.size()
-      && is_separator(m_pathname[end_pos]));
+      && detail::is_directory_separator(m_pathname[end_pos]));
 
     // skip separators unless root directory
     size_type root_dir_pos(root_directory_start(m_pathname, end_pos));
     for (; 
       end_pos > 0
       && (end_pos-1) != root_dir_pos
-      && is_separator(m_pathname[end_pos-1])
+      && detail::is_directory_separator(m_pathname[end_pos-1])
       ;
       --end_pos) {}
 
@@ -362,7 +350,7 @@ namespace filesystem
     size_type pos(filename_pos(m_pathname, m_pathname.size()));
     return (m_pathname.size()
               && pos
-              && is_separator(m_pathname[pos])
+              && detail::is_directory_separator(m_pathname[pos])
               && !is_root_separator(m_pathname, pos))
       ? detail::dot_path()
       : path(m_pathname.c_str() + pos);
@@ -513,11 +501,11 @@ namespace
   bool is_root_separator(const string_type & str, size_type pos)
     // pos is position of the separator
   {
-    BOOST_ASSERT_MSG(!str.empty() && is_separator(str[pos]),
+    BOOST_ASSERT_MSG(!str.empty() && fs::detail::is_directory_separator(str[pos]),
       "precondition violation");
 
     // subsequent logic expects pos to be for leftmost slash of a set
-    while (pos > 0 && is_separator(str[pos-1]))
+    while (pos > 0 && fs::detail::is_directory_separator(str[pos-1]))
       --pos;
 
     //  "/" [...]
@@ -531,7 +519,8 @@ namespace
 # endif
 
     //  "//" name "/"
-    if (pos < 3 || !is_separator(str[0]) || !is_separator(str[1]))
+    if (pos < 3 || !fs::detail::is_directory_separator(str[0])
+      || !fs::detail::is_directory_separator(str[1]))
       return false;
 
     return str.find_first_of(separators, 2) == pos;
@@ -545,11 +534,11 @@ namespace
   {
     // case: "//"
     if (end_pos == 2 
-      && is_separator(str[0])
-      && is_separator(str[1])) return 0;
+      && fs::detail::is_directory_separator(str[0])
+      && fs::detail::is_directory_separator(str[1])) return 0;
 
     // case: ends in "/"
-    if (end_pos && is_separator(str[end_pos-1]))
+    if (end_pos && fs::detail::is_directory_separator(str[end_pos-1]))
       return end_pos-1;
     
     // set pos to start of last element
@@ -561,7 +550,7 @@ namespace
 #   endif
 
     return (pos == string_type::npos // path itself must be a filename (or empty)
-      || (pos == 1 && is_separator(str[0]))) // or net
+      || (pos == 1 && fs::detail::is_directory_separator(str[0]))) // or net
         ? 0 // so filename is entire string
         : pos + 1; // or starts after delimiter
   }
@@ -576,21 +565,21 @@ namespace
     // case "c:/"
     if (size > 2
       && path[1] == colon
-      && is_separator(path[2])) return 2;
+      && fs::detail::is_directory_separator(path[2])) return 2;
 #   endif
 
     // case "//"
     if (size == 2
-      && is_separator(path[0])
-      && is_separator(path[1])) return string_type::npos;
+      && fs::detail::is_directory_separator(path[0])
+      && fs::detail::is_directory_separator(path[1])) return string_type::npos;
 
 #   ifdef BOOST_WINDOWS_API
     // case "\\?\"
     if (size > 4
-      && is_separator(path[0])
-      && is_separator(path[1])
+      && fs::detail::is_directory_separator(path[0])
+      && fs::detail::is_directory_separator(path[1])
       && path[2] == questionmark
-      && is_separator(path[3]))
+      && fs::detail::is_directory_separator(path[3]))
     {
       string_type::size_type pos(path.find_first_of(separators, 4));
         return pos < size ? pos : string_type::npos;
@@ -599,16 +588,16 @@ namespace
 
     // case "//net {/}"
     if (size > 3
-      && is_separator(path[0])
-      && is_separator(path[1])
-      && !is_separator(path[2]))
+      && fs::detail::is_directory_separator(path[0])
+      && fs::detail::is_directory_separator(path[1])
+      && !fs::detail::is_directory_separator(path[2]))
     {
       string_type::size_type pos(path.find_first_of(separators, 2));
       return pos < size ? pos : string_type::npos;
     }
     
     // case "/"
-    if (size > 0 && is_separator(path[0])) return 0;
+    if (size > 0 && fs::detail::is_directory_separator(path[0])) return 0;
 
     return string_type::npos;
   }
@@ -632,22 +621,22 @@ namespace
     string_type::size_type cur(0);
     
     // deal with // [network]
-    if (size >= 2 && is_separator(src[0])
-      && is_separator(src[1])
+    if (size >= 2 && fs::detail::is_directory_separator(src[0])
+      && fs::detail::is_directory_separator(src[1])
       && (size == 2
-        || !is_separator(src[2])))
+        || !fs::detail::is_directory_separator(src[2])))
     { 
       cur += 2;
       element_size += 2;
     }
 
     // leading (not non-network) separator
-    else if (is_separator(src[0]))
+    else if (fs::detail::is_directory_separator(src[0]))
     {
       ++element_size;
       // bypass extra leading separators
       while (cur+1 < size
-        && is_separator(src[cur+1]))
+        && fs::detail::is_directory_separator(src[cur+1]))
       {
         ++cur;
         ++element_pos;
@@ -663,7 +652,7 @@ namespace
 #     ifdef BOOST_WINDOWS_API
       && src[cur] != colon
 #     endif
-      && !is_separator(src[cur]))
+      && !fs::detail::is_directory_separator(src[cur]))
     {
       ++cur;
       ++element_size;
@@ -772,12 +761,12 @@ namespace filesystem
 
     // both POSIX and Windows treat paths that begin with exactly two separators specially
     bool was_net(it.m_element.m_pathname.size() > 2
-      && is_separator(it.m_element.m_pathname[0])
-      && is_separator(it.m_element.m_pathname[1])
-      && !is_separator(it.m_element.m_pathname[2]));
+      && detail::is_directory_separator(it.m_element.m_pathname[0])
+      && detail::is_directory_separator(it.m_element.m_pathname[1])
+      && !detail::is_directory_separator(it.m_element.m_pathname[2]));
 
     // process separator (Windows drive spec is only case not a separator)
-    if (is_separator(it.m_path_ptr->m_pathname[it.m_pos]))
+    if (detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos]))
     {
       // detect root directory
       if (was_net
@@ -793,7 +782,7 @@ namespace filesystem
 
       // skip separators until it.m_pos points to the start of the next element
       while (it.m_pos != it.m_path_ptr->m_pathname.size()
-        && is_separator(it.m_path_ptr->m_pathname[it.m_pos]))
+        && detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos]))
         { ++it.m_pos; }
 
       // detect trailing separator, and treat it as ".", per POSIX spec
@@ -822,7 +811,7 @@ namespace filesystem
     // if at end and there was a trailing non-root '/', return "."
     if (it.m_pos == it.m_path_ptr->m_pathname.size()
       && it.m_path_ptr->m_pathname.size() > 1
-      && is_separator(it.m_path_ptr->m_pathname[it.m_pos-1])
+      && detail::is_directory_separator(it.m_path_ptr->m_pathname[it.m_pos-1])
       && !is_root_separator(it.m_path_ptr->m_pathname, it.m_pos-1) 
        )
     {
@@ -838,7 +827,7 @@ namespace filesystem
       ; 
       end_pos > 0
       && (end_pos-1) != root_dir_pos
-      && is_separator(it.m_path_ptr->m_pathname[end_pos-1])
+      && detail::is_directory_separator(it.m_path_ptr->m_pathname[end_pos-1])
       ;
       --end_pos) {}