From afc50b3ed4b97d9060d9d56fde840217875492a6 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 11 Mar 2014 22:05:42 +0000 Subject: 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. llvm-svn: 203611 --- llvm/lib/Support/Unix/Path.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/lib/Support/Unix/Path.inc') diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 2b29baca738..500b7fecb74 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -272,6 +272,19 @@ error_code create_directory(const Twine &path, bool IgnoreExisting) { return error_code::success(); } +error_code normalize_separators(SmallVectorImpl &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) { -- cgit v1.2.3