support: add a utility function to normalise path separators

Add a utility function to convert the Windows path separator to Unix style path
separators.  This is used by a subsequent change in clang to enable the use of
Windows SDK headers on Linux.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203611 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool
2014-03-11 22:05:42 +00:00
parent ff73a2bf86
commit 404a72729b
4 changed files with 63 additions and 0 deletions

View File

@@ -272,6 +272,19 @@ error_code create_directory(const Twine &path, bool IgnoreExisting) {
return error_code::success();
}
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 error_code::success();
}
// Note that we are using symbolic link because hard links are not supported by
// all filesystems (SMB doesn't).
error_code create_link(const Twine &to, const Twine &from) {