# 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)
# 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
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;
}
&& 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;
}
# 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;
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;
}
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
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
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) {}
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);
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;
// "/" [...]
# 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;
{
// 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
# 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
}
// 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;
// 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;
}
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;
# ifdef BOOST_WINDOWS_API
&& src[cur] != colon
# endif
- && !is_separator(src[cur]))
+ && !fs::detail::is_directory_separator(src[cur]))
{
++cur;
++element_size;
// 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
// 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
// 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)
)
{
;
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) {}