bool isFilesystemCaseSensitive();
/// Extract the path common to both @c p1 and @c p2. DBCS aware!
-/// \p p1 and \p p2 are encoded in ucs4, \returns the index to the
-/// end of the last matching path component (the index may be pointing
-/// to the path separator, if it is the last char in @c p2).
+/// \p p1 and \p p2 are encoded in ucs4, \returns the index to the end of
+/// the last matching path component (the index may be pointing after the
+/// end of @c p1 or @c p2 if their last char is not the path separator).
std::size_t common_path(docstring const & p1, docstring const & p2);
/// Converts a unix style path to host OS style.
--i; // here was the last match
while (i && p1[i] != '/')
--i;
- } else
- --i;
-
+ }
return i;
}
docstring const p2 = from_utf8(pre);
docstring::size_type const p1_len = p1.length();
docstring::size_type const p2_len = p2.length();
- docstring::size_type const common_len = common_path(p1, p2) + 1;
+ docstring::size_type common_len = common_path(p1, p2);
- if (common_len == 1) {
- if (p2_len != 1 || p1_len == 0 || p1[0] != p2[0]
- || (p1_len != 1 && p1[1] != '/'))
- return false;
- } else if (common_len != p2_len)
+ if (p2[p2_len - 1] == '/')
+ ++common_len;
+
+ if (common_len != p2_len)
return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre))
--i; // here was the last match
while (i && p1[i] != '/')
--i;
- } else
- --i;
-
+ }
return i;
}
docstring const p2 = from_utf8(pre);
docstring::size_type const p1_len = p1.length();
docstring::size_type const p2_len = p2.length();
- docstring::size_type const common_len = common_path(p1, p2) + 1;
+ docstring::size_type common_len = common_path(p1, p2);
- if (common_len == 1) {
- if (p2_len != 1 || p1_len == 0 || p1[0] != p2[0]
- || (p1_len != 1 && p1[1] != '/'))
- return false;
- } else if (common_len != p2_len)
+ if (p2[p2_len - 1] == '/')
+ ++common_len;
+
+ if (common_len != p2_len)
return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre))
--i; // here was the last match
while (i && p1[i] != '/')
--i;
- } else
- --i;
-
+ }
return i;
}
docstring const p2 = from_utf8(pre);
docstring::size_type const p1_len = p1.length();
docstring::size_type const p2_len = p2.length();
- docstring::size_type const common_len = common_path(p1, p2) + 1;
+ docstring::size_type common_len = common_path(p1, p2);
- if (common_len == 1) {
- if (p2_len != 1 || p1_len == 0 || p1[0] != p2[0]
- || (p1_len != 1 && p1[1] != '/'))
- return false;
- } else if (common_len != p2_len)
+ if (p2[p2_len - 1] == '/')
+ ++common_len;
+
+ if (common_len != p2_len)
return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre))