/// platform-specific error_code.
std::error_code make_absolute(SmallVectorImpl<char> &path);
-/// @brief Normalize path separators in \a Path
-///
-/// If the path contains any '\' separators, they are transformed into '/'.
-/// This is particularly useful when cross-compiling Windows on Linux, but is
-/// safe to invoke on Windows, which accepts both characters as a path
-/// separator.
-std::error_code normalize_separators(SmallVectorImpl<char> &Path);
-
/// @brief Create all the non-existent directories in path.
///
/// @param path Directories to create.
return std::error_code();
}
-std::error_code normalize_separators(SmallVectorImpl<char> &Path) {
- for (auto PI = Path.begin(), PE = Path.end(); PI < PE; ++PI) {
- if (*PI == '\\') {
- auto PN = PI + 1;
- if (PN < PE && *PN == '\\')
- ++PI; // increment once, the for loop will move over the escaped slash
- else
- *PI = '/';
- }
- }
- return std::error_code();
-}
-
// Note that we are using symbolic link because hard links are not supported by
// all filesystems (SMB doesn't).
std::error_code create_link(const Twine &to, const Twine &from) {
return std::error_code();
}
-std::error_code normalize_separators(SmallVectorImpl<char> &Path) {
- (void) Path;
- return std::error_code();
-}
-
// We can't use symbolic links for windows.
std::error_code create_link(const Twine &to, const Twine &from) {
// Get arguments.
SmallString<64> Path5("\\a");
SmallString<64> Path6("a\\");
- ASSERT_NO_ERROR(fs::normalize_separators(Path1));
+ path::native(Path1);
EXPECT_PATH_IS(Path1, "a", "a");
- ASSERT_NO_ERROR(fs::normalize_separators(Path2));
+ path::native(Path2);
EXPECT_PATH_IS(Path2, "a/b", "a/b");
- ASSERT_NO_ERROR(fs::normalize_separators(Path3));
+ path::native(Path3);
EXPECT_PATH_IS(Path3, "a\\b", "a/b");
- ASSERT_NO_ERROR(fs::normalize_separators(Path4));
+ path::native(Path4);
EXPECT_PATH_IS(Path4, "a\\\\b", "a\\\\b");
- ASSERT_NO_ERROR(fs::normalize_separators(Path5));
+ path::native(Path5);
EXPECT_PATH_IS(Path5, "\\a", "/a");
- ASSERT_NO_ERROR(fs::normalize_separators(Path6));
+ path::native(Path6);
EXPECT_PATH_IS(Path6, "a\\", "a/");
#undef EXPECT_PATH_IS